Quote:
Code:
{ cat abc.txt; echo 'i am fine'; } > tmp.txt ; mv tmp.txt abc.txt
|
While I'm not sure if this is necessary for the task the OP has outlined, the following method to avoid the use of a temp file might be of interest...
Code:
( rm abc.txt; { cat; echo "i am fine"; } > abc.txt ) < abc.txt
Basically, the use of the subshell allows the filename 'abc.txt' to be removed from the file system while continuing to hold the the file open. Because the filename no longer exists, the process within the subshell can create that filename without destroying the input.
Not to everyone's taste but I think it's a pretty cool trick!