LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   need clarification of the script:urgent (https://www.linuxquestions.org/questions/linux-newbie-8/need-clarification-of-the-script-urgent-911269/)

george.m 11-01-2011 11:46 AM

need clarification of the script:urgent
 
#!/bin/bash
pal1=`find /usr/local/ -type f -name messages.1.gz |wc -l`
find /usr/local/ -type f -name messages.1.gz -exec rm {} \;

serafean 11-01-2011 12:35 PM

Hi,

This sounds like homework... and the urgent in the title doesn't help your case :)
I will not explain in detail. I will only give you the necessary information to piece it together yourself.
Here goes :
Code:

$ man find
$ man wc
$ man rm

will tell you what the commands do.
the | symbol redirects the output of the first command to the second (in your case : the output of find to wc ).
pal1= is a variable assignment.
` ..... ` excutes ..... and returns the return value.

I'd recommend some reading about bash programming.

Serafean

george.m 11-01-2011 12:53 PM

you are rite
actually i had a requirement to remove 1 hour old files from the location /usr/var/messages
and need to keep that removed files in a different file as back up

and there is an exciting script running for this job.

unfortunately am not much aware of the shell scripting so couldnt figure out.


can you please help me out

serafean 11-01-2011 01:18 PM

Quote:

i had a requirement to remove 1 hour old files from the location /usr/var/messages
and need to keep that removed files in a different file as back up
Ok, Same as before : use the 'find' command, take a look at the following options
  • -amin
  • -type
  • -exec
and look at the "mv" command. You got the ingredients now, time to cook :)

Serafean


All times are GMT -5. The time now is 09:21 PM.