LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2011, 10:46 AM   #1
george.m
LQ Newbie
 
Registered: Nov 2011
Posts: 2

Rep: Reputation: Disabled
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 {} \;
 
Old 11-01-2011, 11:35 AM   #2
serafean
Member
 
Registered: Mar 2006
Location: Czech Republic
Distribution: Gentoo, Chakra
Posts: 997
Blog Entries: 15

Rep: Reputation: 136Reputation: 136
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
 
Old 11-01-2011, 11:53 AM   #3
george.m
LQ Newbie
 
Registered: Nov 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Red face

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
 
0 members found this post helpful.
Old 11-01-2011, 12:18 PM   #4
serafean
Member
 
Registered: Mar 2006
Location: Czech Republic
Distribution: Gentoo, Chakra
Posts: 997
Blog Entries: 15

Rep: Reputation: 136Reputation: 136
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
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need clarification for file to bash script array. lifeforce4 Programming 3 11-27-2009 10:09 AM
URGENT: Please validate this script PKrishna Linux - Newbie 1 04-01-2008 11:03 AM
[SOLVED] src2pkg python script clarification bassmadrigal Slackware 14 12-09-2007 09:32 AM
need urgent help with bash script ferradura Linux - General 4 09-11-2007 04:32 PM
Need clarification re: Running a script as root. phil1076 Linux - General 5 12-18-2003 01:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration