find command with exec doesnt work


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find command with exec doesnt work
# 1  
Old 07-26-2006
find command with exec doesnt work

Hi There,
I have a script which finds for log files and removes them if the file has changed in the last day.
The script runs fine without errors. The log file is still there. So, I decided to print the find command and run the command outside the script. Getting "Incomplete statement"
Can you give any ideas?
Thank you.
Unix fan.

Script
*****
#!/bin/ksh
log_home="/export/home/n74915/"
set -x
typeset -i10 days_old=${3:-1}
jobid="$1"
print $jobid
print "Cleaning up"
print $(print $jobid)'t.log'
find $log_home -type f -name $(print $jobid)'t.log' -ctime +$days_old -exec rm {} \; #remove outdated log files
print $?
print find $log_home -type f -name $(print $jobid)'t.log' -ctime +$days_old -exec rm {} \; #remove outdated log files
print $?
print "Cleaned up"
# 2  
Old 07-26-2006
If I assign values to
log_home
jobid
days_old

this command gives me no errors:
Code:
find $log_home -type f -name "$jobid""t.log" -ctime +"$days_old"

Does jobid have embedded spaces?
# 3  
Old 07-26-2006
Hi,
Thank you for getting back to me. Jobid doesnt have embedded spaces in it.
I tried the command upto -ctime +1 and didnt get any errors. Its only when I include -exec rm {}\; that I get incomplete statement error. the parameter is not getting passed to rm command ?
Appreciate your help..
# 4  
Old 07-26-2006
Maybe parameter list is too long for exec, try to use xargs and see whats the output.
# 5  
Old 07-26-2006
I dont know how to use that command. Could you give me some example?
# 6  
Old 07-26-2006
lost in space

Code:
-exec rm {}\;

I'm going out on a limb here, but I think you're missing a space
between the last close-curly and the backslash. "Incomplete statement"
is find telling you that it needs something to terminate the -exec clause.
# 7  
Old 07-26-2006
Thank you so much.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux find command seems to not transmit all the result to the '-exec command'

Hello. From a script, a command for a test is use : find /home/user_install -maxdepth 1 -type f -newer /tmp/000_skel_file_deb ! -newer /tmp/000_skel_file_end -name '.bashrc' -o -name '.profile' -o -name '.gtkrc-2.0' -o -name '.i18n' -o -name '.inputrc' Tha command... (3 Replies)
Discussion started by: jcdole
3 Replies

2. UNIX for Dummies Questions & Answers

[SOLVED] Mv command doesnt work in shell script

Hi All, i created the below script to move file with xml extension from one directory to another,but the mv command is not working inside the shell script, #!/us/bin/ksh filepath="/apps/extract" filename="*.xml" foldername=2191POB000_$(date +%Y%m%d%H%M%S) mkdir -p "$filepath/$foldername"... (3 Replies)
Discussion started by: Radhas
3 Replies

3. UNIX for Dummies Questions & Answers

What does the '\' in find -exec command

Hi, I have two scripts that remove files. One works fine and is coded find -name "syst*" -mtime +1 -exec rm {} \; The other is almost the same - only thing missing is the '\'. On that script though I keep getting: rm syst1202.file ? etc Does the \ make that difference or is it a... (3 Replies)
Discussion started by: Grueben
3 Replies

4. Shell Programming and Scripting

find command with -exec

Hi all, Please could someone help with the following command requirement. I basically need to find files NEWER than a given file and order the result on time. My attempt so far is as follows: find . -newer <file_name> -exec ls -lrt {} ;\ But I dont seem to get the right result... (12 Replies)
Discussion started by: jonnyd
12 Replies

5. UNIX for Dummies Questions & Answers

why doesnt it work?

I am trying to print out two fields in a file using awk. So, I have got awk -F '\t' 'NF = 2 {print $1 $2 "]"}' two.txt in a script called what.awk When i run this version like this - ./what.awk then it runs however I want to run the program like this awk -f what.awk two.txt. When I... (8 Replies)
Discussion started by: The undertaker
8 Replies

6. AIX

Vi doesnt work

Hi Guys, I have a strange problem.( AIX 6.1) "vi" is not working at all..Whenever i #vi <anythin> ,, it returns the prompt back. Any clues folks?? (14 Replies)
Discussion started by: muzahed
14 Replies

7. UNIX for Advanced & Expert Users

find -exec with 2 commands doesn't work (error incomplete staement)

Hi Gurues, I need to modify an existing script that uses find to search a folder, and then move its contents to a folder. What I need to do is run gzip on each file after it's moved. So, I ran this little test: Put a ls.tar file on my $HOME, mkdir tmp, and then: virtuo@tnpmprd01: find .... (3 Replies)
Discussion started by: llagos
3 Replies

8. Shell Programming and Scripting

find command with -exec

Hi People, I have a directory full of compressed files (.Z extention) In many of these files there is a string pattern (3800078163033) I want to find all file names which contain this string in their text. Regards, Abhishek (2 Replies)
Discussion started by: max29583
2 Replies

9. UNIX for Dummies Questions & Answers

cp doesnt work - Help

When trying to copy a file in Solaris 8 it doesnt copy file or give a error. This worked 100% until the 29th. I've checked the rights and everything seems fine: drwxrwxrwx 2 bmuser bmgroup 11776 Jan 3 10:32 spool This is the file I want to copy: -rwxrwxrwx 1 bmuser bmgroup ... (26 Replies)
Discussion started by: rudi.okelly
26 Replies

10. HP-UX

ls command doesnt work

Good Day I mistakely renamed the dld.sl file in the /usr/lib directory. When i try to ls/ftp into the box i get this error :eek: crt0: ERROR couldn't open /usr/lib/dld.sl errno:000000002 I have tried to rename it back from the renamed file to the original file name, but it gives me the... (2 Replies)
Discussion started by: shawnbishop
2 Replies
Login or Register to Ask a Question