15 Basic ls examples

Nice! I would go as far as ls -all . Didn't know you could sort by time modified or size. Interesting read! Thanks. :)
 
A quick way to look at the last updated logfile in a directory, assuming you have multiple logs being updated by different precesses:
Code:
while true
do
    LF=`ls -1tr|tail -1`
    tail -20 ${LF}
    sleep 1
    clear
done
Or all in one line:
Code:
while true; do tail -20 `ls -1tr|tail -1`; sleep 1; clear; done
Change values for tail and sleep to vary your output amount, and time to refresh.
 
What is the purpose of the sleep? Is the 1 for 1 second or 1 millisecond?
 
Flipping hell, do you need anything more than ls -al?

Maybe with a | grep xyz?
 
Let's say I wanted to find .jpg files anywhere in (below?) my home directory that were modified in the last 5 days, I simply do:
Code:
find ~ -name "*.jpg" -mtime -5
This is just a very basic example. You could use regular expressions and all kinds of options, like -exec foo{} \;
...

Edit: Oops, I see this thread is more about "ls". :o
 
Last edited:
What is the purpose of the sleep? Is the 1 for 1 second or 1 millisecond?

That is 1 second. If you can scan the output in less time, then you can go into milliseconds by using "sleep 0.5", for example.
 
Top
Sign up to the MyBroadband newsletter
X