Bash the script - Then start crying cos it wont wo - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html) +--- Forum: How Do I? (https://www.linux-noob.com/forums/forum-60.html) +--- Thread: Bash the script - Then start crying cos it wont wo (/thread-2892.html) |
Bash the script - Then start crying cos it wont wo - jimpy90 - 2005-01-26 I am a noob. I can do basic linux stuff but i am trying to write a script to make this easier. I have never written a script before and i am actually suprised that i have got this fat without rm'ing my entire system. I have several directories that cameras upload images to all day. Basically i want this script to run as a cron job and run at midnight every night and delete all but the last 3 days worth of files. I found the easeiest way to find the files was using the `find` command, so i part wrote and part found this command. If i type this in to the console it works :). It will delete all but the last 3 days worth of files. find /path/to/directory/ -mtime +3 -daystart -exec rm {} \; i cant celebrate too soon though. i need this command to run on 5 different directories in: /path/to/directory2/ /path/to/directory3/ /path/to/directory4/ /path/to/directory5/ So i repeat the command 5 times and put it in to a .sh file and try and run it. :s it says find: missing argument to `-exec' 4 times and the last line says: rm: cannot remove `/path/to/directory4/': Is a directory the script as it stands is: Code: cleanup.sh Please any help/advice is welcome Thanks in advance Jim Bash the script - Then start crying cos it wont wo - anyweb - 2005-01-27 pop into #linux-noob on EFNET (IRC) and ask someone there to look at this script issue, i'm sure they'll be able to help you cheers anyweb Bash the script - Then start crying cos it wont wo - z0ny - 2005-01-27 What is the "cleanup.sh" supposed to do in there? Do you really have a script called like that in your $PATH? Does the first line of your script define the interpreter, i.e. "#!/bin/sh"? Bash the script - Then start crying cos it wont wo - znx - 2005-03-24 Quote: Ok... the script can shorten to: Code: #!/bin/sh Don't forget about shell expansion ;) |