Sponsored Content
Top Forums Shell Programming and Scripting help: find and modified files script Post 302245477 by tarunicon on Friday 10th of October 2008 07:40:37 AM
Old 10-10-2008
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 ~]#
 

10 More Discussions You Might Find Interesting

1. HP-UX

find files modified in a specific month

hello i need a way to list files modified in a specific month and move them to a specific directry , i mean somthing like : find . -modifiedtime "May" -print -exec /usr/bin/mv newdirectory thank u (1 Reply)
Discussion started by: omer_ome
1 Replies

2. Solaris

find files modified in a specific month

hello i need a way to list files modified in a specific month and move them to a specific directry , i mean somthing like : find . -modifiedtime "May" -print -exec /usr/bin/mv newdirectory thank u (1 Reply)
Discussion started by: omer_ome
1 Replies

3. UNIX for Advanced & Expert Users

find files modified in a specific month

hello i need a way to list files modified in a specific month and move them to a specific directry , i mean somthing like : find . -modifiedtime "May" -print -exec /usr/bin/mv newdirectory thank u (1 Reply)
Discussion started by: omer_ome
1 Replies

4. Shell Programming and Scripting

Shell script to find out 2 last modified files in a folder..PLZ HELP!!!!!!!!!

hi all, I need to find out the last 2 modified files in a folder.There is some way by which,we can check the timestamp and find out..??please help this is urgent. Thanks in Advance Anju (3 Replies)
Discussion started by: anju
3 Replies

5. Shell Programming and Scripting

find files modified more than a day

Hi All, I am using the below command to check the files modified within last 24hours find /home/karthik -mtime -1 -type f -exec ls -l {} \; What parameter do i need to add in the above command to check the files modified in last 2 or 3 days Kindly let me know if any other alternative... (2 Replies)
Discussion started by: karthikn7974
2 Replies

6. UNIX for Dummies Questions & Answers

how to find the modified files before 60 mins?

hi, I need to find all the modified files before 60 minutes in a folder. Is that possible to find using mtime in minutes? Suggestions please. Thanks for looking into it... Geetha (8 Replies)
Discussion started by: iamgeethuj
8 Replies

7. UNIX for Dummies Questions & Answers

Find last modified date for many files

Hello all - I've looked and have not been able to find a "find" command that will list the last modified date of files within a specific directory and its subdirectories. If anyone knows of such a command it would be very much appreciated! If possible, I would like to sort this output and have... (5 Replies)
Discussion started by: MichaelH3947
5 Replies

8. UNIX for Advanced & Expert Users

find files modified by hours instead of minutes

Is there an easy way to find files modified by hours? If you wanted to find something modified by like 28 hours then I know you could do this: find . -mmin -1440It is pain to break out a calculator and calculate in minutes. Could you do something similar to this? I know I don't have the right... (1 Reply)
Discussion started by: cokedude
1 Replies

9. Shell Programming and Scripting

Find list of files modified for a given day ?

find list of files modified for a given day ? if i have 10 files in my directory, i have modified only 5 ... how to display only modified files ? (1 Reply)
Discussion started by: only4satish
1 Replies

10. UNIX for Advanced & Expert Users

Find files modified in previous minute only

Hi, How can I get files which are modified only in last minute ? it should not display 2 minutes back filels -la -rw-rw-r-- 1 stuser st 51 Dec 3 09:22 a.csv -rw-rw-r-- 1 stiser st 50 Dec 3 09:25 b.csv -rw-rw-r-- 1 stuser st 53 Dec 3 09:33 c.csv When I run command at 9:34am then I... (7 Replies)
Discussion started by: sbjv
7 Replies
GZEXE(1)                                                      General Commands Manual                                                     GZEXE(1)

NAME
gzexe - compress executable files in place SYNOPSIS
gzexe name ... DESCRIPTION
The gzexe utility allows you to compress executables in place and have them automatically uncompress and execute when you run them (at a penalty in performance). For example if you execute ``gzexe /usr/bin/gdb'' it will create the following two files: -rwxr-xr-x 1 root root 1026675 Jun 7 13:53 /usr/bin/gdb -rwxr-xr-x 1 root root 2304524 May 30 13:02 /usr/bin/gdb~ /usr/bin/gdb~ is the original file and /usr/bin/gdb is the self-uncompressing executable file. You can remove /usr/bin/gdb~ once you are sure that /usr/bin/gdb works properly. This utility is most useful on systems with very small disks. OPTIONS
-d Decompress the given executables instead of compressing them. SEE ALSO
gzip(1), znew(1), zmore(1), zcmp(1), zforce(1) CAVEATS
The compressed executable is a shell script. This may create some security holes. In particular, the compressed executable relies on the PATH environment variable to find gzip and some standard utilities (basename, chmod, ln, mkdir, mktemp, rm, sleep, and tail). BUGS
gzexe attempts to retain the original file attributes on the compressed executable, but you may have to fix them manually in some cases, using chmod or chown. GZEXE(1)
All times are GMT -4. The time now is 01:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy