ls - show first 100 entries?

  • Thread starter Thread starter uv
  • Start date Start date

uv

uv

Soldato
Joined
16 May 2006
Posts
8,435
Location
Manchester
I'm trying to find the naming convention of some log files on our server, but there are so many that when I use an 'ls' command, it just hangs..

Is there a command I can use that only displays the first, say 10 found files?

Kinda like the "where rownum < 10" in SQL..
 
Displaying x entries is easy - pipe the ls output into head or tail e.g.
Code:
ls | head -10
will give you the first 10 entries. That might not help if ls itself is timing out, you could try find with appropriate options instead.
 
if ls is hanging, piping it to head probably won't help, the hanging bit would be ls producing all the details before starting to pass it to STDOUT.

You might get better luck by using find with a date modifier on it, e.g.
Code:
find /directory/containing/files -mtime -7

That should give you files modified in the last 7 days, obviously replace 7 with a smaller number if it's liable to give you enough information :)
 
Back
Top Bottom