script using find command.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script using find command.
# 1  
Old 03-24-2009
script using find command.

Hi,Smilie

find /etc /bin /usr/bin /usr/sbin /var/adm \ -name '*.a' \ '!' '(' -user root -o -user daemon -o -user bin -o -user sys -o -user adm -o -user uucp -o -user nuucp -o -user lpd -o -user imnadm -o -user ipsec -o -user ldap -o -user lp -o -user snapp -o -user invscout ')' \ '!' '(' -group system -o -group security -o -group bin -o -group sys -o -group adm -o -group uucp -o -group mail -o -group printq -o -group cron -o -group audit -o -group shutdown -o -group ecs -o -group imnadm -o -group ipsec -o -group ipsec -o -group ldap -o -group lp -o -group haemrm -o -group snapp -o -group hacmp')' \ -ls


ABove is the sequence of commands that I am trying to execute. The problem is , if the find command does not find any *.a file whose owner is one of the system userids which we have mentioned in the comamnd sequence above , then it stops execution with an error message( User does not exist) and does not get further.Ideally we want the command sequence above to dispaly those *.a files which are owned by general userids other than the system userids mentioned above.Is there any way of ignoring this error message to continue the execution till the end .?


Thanks in advance...Smilie

Last edited by sakthilinux; 03-24-2009 at 03:27 AM..
# 2  
Old 03-24-2009
Please help me..
# 3  
Old 03-24-2009
Quote:
Originally Posted by sakthilinux
Please help me..
Please try redirecting all the warnings to infinite sink ...
i.e. "your command" followed by 2>/dev/null
# 4  
Old 03-24-2009
Thanks for your prompt reply. the suggestion you have given me has block the error msg. but the execution of the command sequence it still stoping, i want the entire command sequence to execute without any error message. (The user name does not exist.)

what im trying to say here is , during execution if it encounters a System User which is not therre on the server , the execution must ignore the user and go for the next user included in the command sequence. This is not happening as of now. The command sequence which I am referring to is as follows :

find /etc /bin /usr/bin /usr/sbin /var/adm \ -name '*.a' \ '!' '(' -user root -o -user daemon -o -user bin -o -user sys -o -user adm -o -user uucp -o -user nuucp -o -user lpd -o -user imnadm -o -user ipsec -o -user ldap -o -user lp -o -user snapp -o -user invscout ')' \ '!' '(' -group system -o -group security -o -group bin -o -group sys -o -group adm -o -group uucp -o -group mail -o -group printq -o -group cron -o -group audit -o -group shutdown -o -group ecs -o -group imnadm -o -group ipsec -o -group ipsec -o -group ldap -o -group lp -o -group haemrm -o -group snapp -o -group hacmp')' \ -ls


For eg : If 'sys' user is not found the command sequence should ignore this and check other users which follows .

# 5  
Old 03-24-2009
For all others who might go through this thread , kindly take it up as a challenge , and check if you could crack it. It's an ultimate test of your Unix skills guys . So , kindly work on this and give me your suggestions..!!

Thanks..!!Expecting a lot of responses .. ;-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find command in shell script

Hi all, Please i need an explanation for the following statements ref_file=/tmp/cleanfiles export ref_file touch `TZ=WAT+2 date "+%Y%m%d%H%M"` $ref_file find . ! -name . -prune -type f ! -newer $ref_file -exec store_file.sh {} \; (1 Reply)
Discussion started by: anish_1982
1 Replies

2. Shell Programming and Scripting

Find command in Shell Script

hi I am a newbee in Shell scripting (hardly 7 days) I have to execute a shell script which looks like this #!/bin/sh var1=`date +"%Y%m%d"` echo $var1 find . -name "$var1*" -exec mv {} Delete/ \; the find command in the script is running independently but when kept in this script it is... (24 Replies)
Discussion started by: sweetnsourabh
24 Replies

3. Shell Programming and Scripting

find command in shell script

Hi, dirs.conf fine contains below data /a/b/c/dir1|50 /a/b/c/dir2|50 /a/b/c/dir3|50 In a shell script I do as below while read file_rec do dir_name=`echo "${file_rec}" | cut -d "|" -f 1` purge_days=`echo "${file_rec}" | cut -d "|" -f 2` if then... (3 Replies)
Discussion started by: icefish
3 Replies

4. Shell Programming and Scripting

Find command script

Hi, I want write a script to zip the files in a directory with are not having *.gz extension files. exp: source directory haveing *.log,*.sal,*.txt,*.gz....and some of files with out extension. so i want ZIP the files which are not *.gz files in the same directory. i worte like this: ... (2 Replies)
Discussion started by: koti_rama
2 Replies

5. UNIX for Dummies Questions & Answers

Using the find command in a script

I am new to Shell scripting.Please give some guidence How to place a find command in my shell script? (6 Replies)
Discussion started by: dineshmurs
6 Replies

6. Shell Programming and Scripting

find command and wrapping in the script

Hello, I've been trying to use find command to find and print out some files. When I execute the command on the command line I get the output as expected howerver when I run it in the script it doesn't wrap. For example, this is nicely wraped find /etc -perm -o=w -exec ll '{}' \;... (4 Replies)
Discussion started by: mirusko
4 Replies

7. Shell Programming and Scripting

script to find whether shell command is available

I am running shell scripts on windows using Cygwin tool. In my shell scripts, i want to add an error check, that verify whether a certain command is available or not. For example if SED comamnd is not available in Cygwin, then it should exit with error message. How do i write such shell... (2 Replies)
Discussion started by: mmunir
2 Replies

8. UNIX for Dummies Questions & Answers

Shell script 'find' command

I have a script that has the following command: find /home/user -name test.dat The script works as desired when running normally. However, when I run the script preceding it with 'sh', it fails. Is there something I need to account for when preceding the execution of the script with 'sh'? (1 Reply)
Discussion started by: bsavitch
1 Replies

9. UNIX for Advanced & Expert Users

find command from a shell script

Hi experts, I have a shell script (korn shell on aix) where I am giving find command with file options which are read from a configuration file. For some reason I am getting an error find: 0652-017. I have put set -x in the shell script and the command looks okay. If I cut it and paste it in the... (6 Replies)
Discussion started by: kodermanna
6 Replies

10. Solaris

Find Command In Script

I've got two find commands that work when executed from the command line, but don't work when added to an existing script that runs via Cron. The commands: find /unifi_dev_bkup/database/backup_files/prod -name `date +%y`* -mtime +0 -exec rm -r {} \; find /unifi_dev_bkup/aifiles/prod -name... (3 Replies)
Discussion started by: kdreaves
3 Replies
Login or Register to Ask a Question