Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i search file, check size, and tar at the same time

Status
Not open for further replies.

redhotchilibanana

Programmer
Jul 13, 2003
3
CA
Hi!

Im a new bash shell user and im just wondering how i could see all my files in different directories and get only the 20 biggest .txt files and tar it. Im trying to pipe in ls, awk, head, and tar commands but still i dont get the correct result. please help me on this! it will be greatly appreciated.


redhotchilibanana
 
[tt]find . -type f -name '*.txt' -exec ls -l '{}' ';' | gawk '{ printf &quot;%s %s\n&quot;, $5, $NF }' | sort -n -r | gawk 'NR <= 20 { print $2 }' > largest-files
tar -cf filename.tar --files-from=largest-files[/tt]
should do it.

//Daniel
 
Thanks man! you're such a life saver!! can't do it without you!!! :)

redhotchilibanana
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top