I'm quite new to shell scripting and with my introduction to pipes and the beginners ls and tail commands I was able to come up with quite a simple shell script to find the last modified file in a directory.
The idea is very simple, its built on top of three facts :
1) ls -t -r command which sorts the file in a directory by creation date in reverse order,
2) tail -n 1 command which outputs the last line of the input passed to it, and
3) '' , the pipe which redirects the output of one process to the input of another.
So finally I came up with this simple script :)
ls -t -r | tail -n 1
7 comments :
Post a Comment
ls -t | awk '{print $1}'
He says this is a more appropriate way of doing it
[url=http://forexrobot-review.info]best forex software[/url] [url=http://gayz.pl/forum/viewtopic.php?p=4675#4675]unlock iphone[/url]
Just thought this would be a nice way to introduce myself!
Sincerely,
Edwyn Sammy
if you're ever bored check out my site!
[url=http://www.partyopedia.com/articles/casino-party-supplies.html]casino shower Party Supplies[/url].
Testing the reply feature
Post a Comment