Sponsored Content
Top Forums Shell Programming and Scripting Check my script and correct the find command if wrong Post 302570312 by anuragpgtgerman on Thursday 3rd of November 2011 02:40:52 AM
Old 11-03-2011
Check my script and correct the find command if wrong

Hello All,

Here I am trying to find all the directories whose name starts with EFS or HOTFIX like in below example and below is my code but I don’t know why this is not working correctly.


Code:
drwxr-xr-x 3 qabuild denccefs  4096 Sep 23 21:36 EFS110929A_SOURCE/
-rwxrwxr-x 1 qabuild denccefs   242 Oct 31 09:29 tt1*
-rwxrwxr-x 1 qabuild denccefs   943 Oct 31 11:08 FetchCode*
-rwxrwxr-x 1 qabuild denccefs  7250 Nov  1 08:12 FetchCode1*
drwxr-xr-x 3 qabuild denccefs  4096 Nov  2 06:49 EFS111027B_SOURCE/
-rwxrwxr-x 1 qabuild denccefs  7982 Nov  2 13:10 FetchCode2*
-rwxrwxr-x 1 qabuild denccefs  8083 Nov  2 15:25 FetchCode3*
drwxr-xr-x 3 qabuild denccefs  4096 Nov  2 17:18 EFS111013B_SOURCE/
-rw-rw-r-- 1 qabuild denccefs 60603 Nov  2 17:21 Default.aspx
-rw-rw-r-- 1 qabuild denccefs    11 Nov  3 03:24 NGGF_Release.txt
drwxrwxr-x 2 qabuild denccefs  4096 Nov  3 03:33 Temp/
-rwxrwxr-x 1 qabuild denccefs  8049 Nov  3 06:30 FetchCode4*

Code:
show_command()
{
 while [ $# -gt 0 ]
 do
  echo -e "\n";
  echo '=======================================================================================================================';
  echo "Command/s used for getting the list of files/output below is/are as follows:"; echo;
  echo "\$ ${1}"; echo;
  echo '=======================================================================================================================';
 
################################################################################################
## To make $n --> $n-1 i.e $1 will become $2 once the below "shift" command will be called.   ##
################################################################################################
 
  shift;
 done
}
 
SourceCodelogs()
{
 
cmd="find /efare1/home/qabuild/rohit -maxdepth 1 \( -name "EFS*" -o -name "HOTFIX*" \) -mtime -5 -type d -print 2>/dev/null";
#cmd="find /efare1/home/qabuild/rohit -maxdepth 1 -type d -name "*_SOURCE" -mtime +5 -print 2>/dev/null";
 
 show_command "${cmd}";
 
 for TARGET in `eval ${cmd}`
 do
  echo "1 --> * removing... ${TARGET}"
 # rm -frv ${TARGET}
 done
}
 
SourceCodelogs

See the below output when I run this command directly
Code:
[/efare1/home/qabuild/rohit] $ cmd="find /efare1/home/qabuild/rohit -name "EFS*" -mtime -5 -type d -print 2>/dev/null";
 
[/efare1/home/qabuild/rohit] $ echo $cmd
find /efare1/home/qabuild/rohit -name EFS110929A_SOURCE EFS111013B_SOURCE EFS111027B_SOURCE -mtime -5 -type d -print 2>/dev/null
 
[/efare1/home/qabuild/rohit] $ find /efare1/home/qabuild/rohit -name "EFS*" -mtime -5 -type d -print
/efare1/home/qabuild/rohit/EFS111013B_SOURCE
/efare1/home/qabuild/rohit/EFS111027B_SOURCE

Thanks

Last edited by pludi; 11-03-2011 at 05:50 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I check that a password is correct?

Hi there, There's something I don't understand. The same string does not give the same md5 hash everytime. I wanted to find a way to check someone's password but the following script obviously shows that it's not possible that way : ks354286:~# user=foo ks354286:~# pw=$(mkpasswd -H md5... (3 Replies)
Discussion started by: chebarbudo
3 Replies

2. UNIX for Advanced & Expert Users

what is wrong with this find command

i am trying to find the files which are more than 100MB and it was created 10 days ago. find /lola/loaded -size +102400 -mtime -10 -print | xargs ls -ltr -rw-rw-r-- 1 lola_adm gdrmp 82054170 Jun 23 06:17 /lola/loaded/ILMEMBER20090622.txt -rw-rw-r-- 1 lola_adm gdrmp 652080494 Jun 24... (3 Replies)
Discussion started by: sudhiroracle
3 Replies

3. Shell Programming and Scripting

Wrong output in find command

Hi guys - I am trying a small script to tell me if there is a file that exists less than 1k. It should report ERROR, otherwise the check is good. I wrote this script down, however it never runs in the if/then statement. It always returns the echo ERROR. MYSIZE=$(find /home/student/dir1... (8 Replies)
Discussion started by: DallasT
8 Replies

4. Shell Programming and Scripting

WORD SEARCH - CHECK IF CORRECT!

Im currently working on a Script using PICO editor, the scripts purpose is : When you typed a certain "word" and press enter, All directories, Script, and any other files that contain that "word" will be displayed.. for example i typed "DOG".. all executable script, Directories, and any other... (3 Replies)
Discussion started by: jenimesh19
3 Replies

5. Shell Programming and Scripting

Not correct processing of “\ “ in names of dirs inside shell script (tar command - system backup scr

Hello, Recently, I've started with shell scripting, and decided to write a script for my system backup using tar. When I was dealing with tar execution inside shell script I found this, inside shell we have the following code: tar $TAR_PARAMS $ARCHIVE_FILE $EXCLUDE $BACKUP_STARTwith... (6 Replies)
Discussion started by: ilnar
6 Replies

6. Solaris

run a service via startup script (correct me if I am wrong)

Environment Solaris 9 I have configured the Solaris9 as NTP client in which Solaris9 is syncing the time with a windows2008 R2 Server which is runing fine. Now I want that the xntpd service should start at startup. I did this via a script. Kindly correct if I did any thing wrong: 1.)Made... (9 Replies)
Discussion started by: z_haseeb
9 Replies

7. Shell Programming and Scripting

perl script to check the mail ids in the correct format or not

Hi Folks, I have few mailids in a text file and need to check whether the mailid is in correct format or not. If just to check whether the string is a mailid or not there is a perl module Email::Valid to do the business or we can implement our own logic. But the mail_ids I am having is... (4 Replies)
Discussion started by: giridhar276
4 Replies

8. Shell Programming and Scripting

How to check if date format is correct?

Hi! how do i know if the input is the same as the required date format? the date should be dd/mm/YYYY ex. 2/3/2012 or 15/11/2012 all the following conditions must return an error: *input of string *day is > 31 or < 1 *month is > 12 or < 1 *year is < 2013 suppose the date format is stored... (1 Reply)
Discussion started by: angilulu
1 Replies

9. Shell Programming and Scripting

Shell script to find the wrong filename in a path and raise a trap for it

Example: I have server name A with an IP : 125.252.235.455 I have an username /password to login into this server under SSH connection In this server i have a path /apps/user/filename(Big.txt) Everyday we used to get the filename as Big.txt. I want a shell script to monitor this path... (4 Replies)
Discussion started by: ChandruBala73
4 Replies

10. Shell Programming and Scripting

Same sed code prints(p) correct, but writtes(w) wrong output

Dear all, I am using sed as an alternative to grep in order to get a specific line from each of multiple files located in the same directory. I am using sed because it prints the lines in the correct order (unlike grep). When I write sed code that prints out the output I get it correct, but... (1 Reply)
Discussion started by: JaNaJaNa
1 Replies
MOUNT_EFS(8)						    BSD System Manager's Manual 					      MOUNT_EFS(8)

NAME
mount_efs -- Mount an SGI EFS file system SYNOPSIS
mount_efs [-o options] special node DESCRIPTION
The mount_efs command attaches an EFS file system special device on to the file system tree at the point node. Both special and node are converted to absolute paths before use. This command is normally executed by mount(8) at boot time. The options are as follows: -o Options are specified with a -o flag followed by a comma-separated string of options. See the mount(8) man page for possible options and their meanings. SEE ALSO
mount(2), unmount(2), options(4), fstab(5), mount(8), svhlabel(8) HISTORY
The mount_efs utility first appeared in NetBSD 5.0. BUGS
Write support is not presently implemented. EFS file systems are limited to 8 gigabytes in size. Because of EFS limitations, an EFS file system can't be used with any UID or GID greater than 65535. BSD
June 19, 2007 BSD
All times are GMT -4. The time now is 05:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy