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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting to a file

Status
Not open for further replies.

lampshade

Programmer
Nov 20, 2008
6
0
0
US
Im searching the system with this command:

Code:
find / -true -exec ls -l {} 2>/dev/null \; |\
egrep '2008-10-01 00:00 | 2008-10-02 00:00' | sort -f

And its taking soooo long for anything to come up..
Is there anyway to rewrite it so that it wont take forever?
And for the 'sort -f' is that the correct function for files in alphabetical order?
 
Hi

Depends on you [tt]find[/tt]'s capabilities.

If it supports the -printf option you can format its output so there will be no need for [tt]ls[/tt].

If it supports the -mtime option you can filter its output so there will be no need for [tt]grep[/tt].

If if supports the -type option you can exclude directories from the output ( as far as I see you do not need them ) so the amount of data to process will be dramatically reduced. ( Note that [tt]ls[/tt] on a directory lists its content, so your [tt]find[/tt] + [tt]ls[/tt] combination will double the output. )

Beside the above consider using [tt]xargs[/tt] to reduce the amount of executed [tt]ls[/tt] commands.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top