[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash: inserire stringa di testo in cima a un file (non in coda)



Pisvi Gabriele! On Thu, Nov 06, 2008 at 12:11:53PM +0100 you wrote:

>> Qualcosa tipo:
>> echo stringa di testo && cat myfile > myfile?
> Del tipo… ma non funzia… alla fine del comando ho myfile completamente  
> vuoto…

Bisogna passare per un file temporaneo

TMPFILE=`tempfile`
(echo "nuovastringa" && cat myfile) > $TMPFILE
mv $TMPFILE myfile

Ciao.
-- 
Massimiliano Masserelli
-------------------------------------------------------------------------------
"It's curtains for you, Mighty Mouse!  This gun is so futuristic that even
*I* don't know how it works!"
		-- from Ralph Bakshi's Mighty Mouse


Reply to: