find + tail + grep

Pavel Urban urbanp na mlp.cz
Úterý Prosinec 28 12:10:26 CET 2004


Pavel Zenisek wrote:
> Ahoj,
> 
> potreboval bych poradit jak smazat vsechny soubory, ktere maji na svem 
> poslednim radku urcity text. Zatim se mi je nepodarilo ani vypsat.
> 
> doposud jsem skoncil s necim takovym:
> 
> find . -exec "tail -n 1 {} | grep HLEDANY {}"  \;  -print
> 
> coz ale nefunguje :-(
> 
> Poradite mi nekdo jak na to?
> 
> Diky

find . -type f -print0 |xargs -0 tail -n 1 |awk '/HLEDANY/{print x};{x=$0}'

Neni to vubec hezke, ale funguje to. Vyhodi to jmeno souboru ve tvaru 
'==> ./soubor <==', jak uz to tail delava. S awkem moc neumim, nejspis 
by to zvladnul sam, ale jak... to uz se ptejte jinde.


-- 
***********************************************************************
Pavel Urban (pavel.urban na ct.cz)
IOL system disaster
Internet OnLine, www.iol.cz (owned by Czech Telecom, www.ct.cz)
***********************************************************************
    Vegetables should not operate electronic equipment.
           Computer Stupidities, http://rinkworks.com/stupid/
***********************************************************************


Další informace o konferenci Linux