Portál AbcLinuxu, 7. listopadu 2025 07:16
perl -pi to bohužel takhle dělá...
$ echo -e 'hello\nworld' >test1 $ ln test1 test2 $ ls -li test? 1081450 -rw-r--r-- 2 michal michal 12 May 10 17:51 test1 1081450 -rw-r--r-- 2 michal michal 12 May 10 17:51 test2 $ sed -i '1aprostě z jednoho souboru (odkazovaného víckrát) udělá dva.' test1 $ head test? ==> test1 <== hello
world ==> test2 <== hello world $ ls -li test? 1081452 -rw-r--r-- 1 michal michal 16 May 10 17:52 test1 1081450 -rw-r--r-- 1 michal michal 12 May 10 17:51 test2
sed.
while( readline(INFILE, line) AND NOT IsItTheLineAfterWhichWantInsert(line) )
writeline(OUTFILE, line)
writeline(OUTFILE, insertedline)
while( readline(INFILE, line) )
writeline(OUTFILE, line)
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.