![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| find files modified more than a day | karthikn7974 | Shell Programming and Scripting | 2 | 08-18-2008 07:07 AM |
| Shell script to find out 2 last modified files in a folder..PLZ HELP!!!!!!!!! | anju | Shell Programming and Scripting | 3 | 02-01-2008 01:47 AM |
| find files modified in a specific month | omer_ome | UNIX for Advanced & Expert Users | 1 | 07-02-2006 10:43 AM |
| find files modified in a specific month | omer_ome | SUN Solaris | 1 | 07-02-2006 10:38 AM |
| find files modified in a specific month | omer_ome | HP-UX | 1 | 07-02-2006 10:36 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I don't know if this *has* to use find... I hope a different approach is OK. The ls command has the ability to sort by modification time. For example, the command ls -alt will sort by mod time, showing long format for all files.
I hope tcsh is acceptable... that's the shell that happened to pop to mind... Code:
#!/bin/tcsh echo -n "What directory do you want to check? " set dir = $< ls -alt $dir | tail +2 | head -n 1 |
|
|||||
|
thanks vidyasagar , treesloth and cfajohnson ..u guys are awesome and truly rockstars ..well treesloth i tried running ur script it gave me some errors here was one of the outputs frm ur script
"What directory do you want to check? /usr/bin/tail: cannot open `+2' for reading: No such file or directory" the script looked like this #!/bin/bash /(Changed from /bin/tcsh to /bin/bash)/ echo -n "What directory do you want to check? "; set dir = $; /bin/ls -alt $dir | /usr/bin/tail +2 | /usr/bin/head -n 1 ; i edited the file and put the whole path of the ls tail and head commands . and the output of command ls -lrt is total 128 -rw-r--r-- 1 root root 4478 Sep 17 08:28 install.log.syslog -rw-r--r-- 1 root root 32645 Sep 17 08:28 install.log -rw------- 1 root root 1232 Sep 17 08:28 anaconda-ks.cfg -rw-r--r-- 1 root root 480 Sep 24 06:38 gvustudentsbatch1.txt -rw-r--r-- 1 root root 78 Sep 26 07:32 a.txt -rw-r--r-- 1 root root 66 Sep 26 07:37 b.txt drwxr-xr-x 9 root root 4096 Oct 8 16:04 Desktop -rw-r--r-- 1 root root 0 Oct 8 16:25 tarun -rw-r--r-- 1 root root 0 Oct 8 16:26 a -rwxrwxrwx 1 root root 81 Oct 8 18:44 latest.sh drwxr-xr-x 2 root root 4096 Oct 8 18:46 untitled folder -rwxrwxrwx 1 root root 122 Oct 10 16:12 mod.sh -rwxrwxrwx 1 root root 191 Oct 10 16:15 mod1.sh cfajohnson i tried running ur script too ..it ran perfectly fine it solved first part of desired result which i wanted ...but the thing is .i ran your script , it was asking for a input from the user ...after that the script exited and returned nothing..as in the script ran it asked me to enter the name of the directory i wanted to find the modified files in ..then the output was blank here is the output [root@server1 ~]# ./mod1.sh /(i renamed the script as mod1.sh)/ Enter the directory you want to search in: /root /(i gave /root directory)/ [root@server1 ~]# |
|
|||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|