Re: [ilugd] how to get latest created file
Gora Mohanty [EMAIL PROTECTED] writes: ls -lr | tail -1 for time of last access. See ls -t, and ls -c for other times. And if you're interested in the dotfiles (the otherwise invisible ones) make it ls -lart (that sequence of letters is ez 2 rmmbr if u r l33t ;-)). PJ ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
On Tue, 13 Nov 2007 10:14:14 +0530, मनीष [EMAIL PROTECTED] said: Ankit Can anyone tell me, how to get latest created file from a folder Ankit to be used in shell script? Bimal you may also take a look at find command with time parameter, see man find for more details. You mean -mtime, -atime and -ctime options? But this will also not give latest `created' file. Let's hear from Ankit if he found what he was looking for. Hmm. % cd $dir % ls -last | head -n 3 Seems to work for me. If you want the output to be easier to parse, and to ignore . and .., use: % ls -t | head -n 1 manoj -- You can drive a horse to water, but a pencil must be lead. Manoj Srivastava [EMAIL PROTECTED] http://www.golden-gryphon.com/ 1024D/BF24424C print 4966 F272 D093 B493 410B 924B 21BA DABB BF24 424C ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
[ilugd] how to get latest created file
Can anyone tell me, how to get latest created file from a folder to be used in shell script? Thanks Rgds Ankit ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
On Nov 12, 2007 5:13 PM, ankIT WALiA [EMAIL PROTECTED] wrote: Can anyone tell me, how to get latest created file from a folder to be used in shell script? I believe this will work, but only in current directory ( not recursively ) ls -l | grep -v '^total' | tr -s ' ' | sort -t ' ' -k 6,7 | tail -1 | cut -f 8 -d' ' -- o1p2e3n4g5l6 http://saleem.a.ansari.googlepages.com/ http://www.jmilug.org/ http://www.csijmi.com/ Linux User #414799 (http://counter.li.org/) ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
On Nov 12, 2007 5:13 PM, ankIT WALiA [EMAIL PROTECTED] wrote: Can anyone tell me, how to get latest created file from a folder to be used in shell script? Try this: getLatestFile(){ if [ $# -eq 1 ]; then ls -tr $1 | tail -1 else echo usage: getLatestFile dir fi } ex. $ getLatestFile ~ $ getLatestFile . $ getLatestFile /tmp HTH, -- Manish ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
On Mon, 2007-11-12 at 17:34 +0530, Saleem Ansari wrote: On Nov 12, 2007 5:13 PM, ankIT WALiA [EMAIL PROTECTED] wrote: Can anyone tell me, how to get latest created file from a folder to be used in shell script? Well, you can't get the time of creation of a file, as that is not stored. You can get various other times, such as the time of modification, time of access (unless this has been turned off at the filesystem level), and time of modification of file status. I believe this will work, but only in current directory ( not recursively ) ls -l | grep -v '^total' | tr -s ' ' | sort -t ' ' -k 6,7 | tail -1 | cut -f 8 -d' ' Eek, try, ls -lr | tail -1 for time of last access. See ls -t, and ls -c for other times. Regards, Gora ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
On Nov 12, 2007 6:00 PM, मनीष [EMAIL PROTECTED] wrote: On Nov 12, 2007 5:13 PM, ankIT WALiA [EMAIL PROTECTED] wrote: Can anyone tell me, how to get latest created file from a folder to be used in shell script? Try this: getLatestFile(){ if [ $# -eq 1 ]; then ls -tr $1 | tail -1 else echo usage: getLatestFile dir fi } ex. $ getLatestFile ~ $ getLatestFile . $ getLatestFile /tmp Gora Well, you can't get the time of creation of a file, as that is Gora not stored. You can get various other times, such as the time Gora of modification, time of access (unless this has been turned off Gora at the filesystem level), and time of modification of file status. @Ankit, Gora is right, file creation time is not stored. What above code gives you is the latest `modified' (not necessarily created) file. -- Manish ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
On Monday 12 November 2007 17:13, ankIT WALiA wrote: Can anyone tell me, how to get latest created file from a folder to be used in shell script? If you want the last file whose inode was modified (which is usually the same as the last file created): ls -c | head -1 P.S. *nix has ``directories'', not ``folders'' ;) Regards, -- Raju -- Raj Mathur[EMAIL PROTECTED] http://kandalaya.org/ Freedom in Technology Software || February 2008 || http://freed.in/ GPG: 78D4 FC67 367F 40E2 0DD5 0FEF C968 D0EF CC68 D17F PsyTrance Chill: http://schizoid.in/ || It is the mind that moves ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
On Nov 12, 2007 5:34 PM, Saleem Ansari [EMAIL PROTECTED] wrote: On Nov 12, 2007 5:13 PM, ankIT WALiA [EMAIL PROTECTED] wrote: Can anyone tell me, how to get latest created file from a folder to be used in shell script? I believe this will work, but only in current directory ( not recursively ) ls -l | grep -v '^total' | tr -s ' ' | sort -t ' ' -k 6,7 | tail -1 | cut -f 8 -d' ' Yet again, here is a Ruby one liner: ruby -e 'puts Dir[./**/*].delete_if { |f| File.directory?(f) }.sort_by { |f| File.mtime(f) } [ -1 ]' Also that it works recursively. -- o1p2e3n4g5l6 http://saleem.a.ansari.googlepages.com/ http://www.jmilug.org/ http://www.csijmi.com/ Linux User #414799 (http://counter.li.org/) ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
ankIT WALiA wrote: Can anyone tell me, how to get latest created file from a folder to be used in shell script? iNotify ? -- Karanbir Singh : http://www.karan.org/ : [EMAIL PROTECTED] ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 ,--[ On Mon, Nov 12, 2007 at 04:20:54PM +, Karanbir Singh wrote: | ankIT WALiA wrote: | Can anyone tell me, how to get latest created file from a folder to be | used in shell script? | | | iNotify ? inotify will throw events, one has to listen to it. I think OP just wanted to get latest created file in a directory, not to listen for files creation events. | -- | Karanbir Singh : http://www.karan.org/ : [EMAIL PROTECTED] HTH - -- Ashish Shukla आशीष शुक्ल http://wahjava.wordpress.com/ ·-- ·- ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- -- -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFHOKdYHy+EEHYuXnQRAlZkAJ9+S5lHAeCmTA8sAP9PbAt0OyuOLwCg7Ajs nI5mF2rCcVu1Fwv2bKw7eEc= =r+Yi -END PGP SIGNATURE- ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
[ilugd] how to get latest created file
Dear Ankit, Message: 8 Date: Mon, 12 Nov 2007 17:13:25 +0530 From: ankIT WALiA [EMAIL PROTECTED] Subject: [ilugd] how to get latest created file To: ilugd@lists.linux-delhi.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1 Can anyone tell me, how to get latest created file from a folder to be used in shell script? Thanks Rgds Ankit you may also take a look at find command with time parameter, see man find for more details. hope this will help you. regards, Bimal Pandit ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] how to get latest created file
Ankit Can anyone tell me, how to get latest created file from a folder to be Ankit used in shell script? Bimal you may also take a look at find command with time parameter, see man find for more details. You mean -mtime, -atime and -ctime options? But this will also not give latest `created' file. Let's hear from Ankit if he found what he was looking for. -- Manish ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/