Re: Problem in making a script



amritpal pathak wrote:
But
still i am little bit confuse to understand it "how it is
happening".Please sir,tell me what each line is doing .It will make
me fully understand it

TEMP=$(mktemp)

Make a temporary file which doesn't conflict with existing files.

head -n $((4 - 1)) "abc.tex" > "$TEMP"

Copy the first lines from the original file to the temporary file.

echo "$fname" >> "$TEMP"

Append the user input to the temporary file.

LEN=$(cat "abc.tex"|wc -l)
tail -n $(($LEN - 4)) "abc.tex" >> "$TEMP"

Append the remaining lines from the original file to the temporary file.

mv "$TEMP" "abc.tex"

Replace the original file by the temporary file.

If you want to learn more about the individual commands, please read the
man pages:

man mktemp head echo cat wc tail mv


Nils

--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



Relevant Pages

  • RE: Locked for editing???
    ... removable disk, such as a floppy diskette, the disk has been removed. ... file name and places this file in the same folder as the original file. ... The process was interrupted while creating the temporary file because you ... If the interruption was caused ...
    (microsoft.public.excel.setup)
  • Re: Newbie howto question.
    ... I can identify the tagged information, ... >said info and write it to the html file, ... create a new temporary file for writing ... read the first line from original file. ...
    (comp.programming)
  • Re: Serialized r/w access to a collection from multiple processes - DLL or EXE?
    ... one or more instances of our app EXEs will be accessing the same ... Flush memory content into new temporary file. ... If write succeeds, then rename original file. ...
    (microsoft.public.vc.language)
  • RE: How is the ~$... file created when you open a document used?
    ... This temporary file holds the logon name of the person ... If the Owner File is damaged or missing the error message changes to: ... Word automatically deletes the Owner File when the original file is closed. ... I understand that Word opens a "copy" of the file and you ...
    (microsoft.public.word.docmanagement)
  • Re: c++ fstream writing to existing file
    ... rewind the original file. ... copy the contents from the temporary file back to the original. ... The universe is a figment of its own imagination. ...
    (comp.lang.cpp)