Results 1 to 3 of 3
Hi Everyone!
New to Linux Forums
Working with Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
Working at a new company, and the previous guy had created a ...
- 03-22-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
Breaking down a script
Hi Everyone!
New to Linux Forums
Working with Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
Working at a new company, and the previous guy had created a shell script to take care of a specific task. His role was unique as the manager took advantage of his programming ability (wasn't a part of his job). On top of that, I'm no programmer either
. I'm trying to figure out what this script is doing because it's throwing a warning.
REM this is remove /home/public/ccnf* (remove anything that starts with ccnf)
rm /home/public/ccnf*
REM i understand that this retrieves anything that starts with ccnf that has been changed at any given time, but I don't understand anything else after -ctime...
find /usr/CC/DATA1/RPT/ -name "ccnf*" -ctime -1 -print | xargs fgrep -l "GB-1 " > /tmp/t.file
REM while read line = read each line that is "printed" from the above command?
while read line
do
REM copy each line that was read from above command to /home/public/
cp -p $line /home/public/
REM don't know about this one =(
done < /tmp/t.file
REM remove /tmp/t.file that was made by previous command?
rm /tmp/t.file
If someone can help me break this down and fill in the shady spots for me that would be great
Last edited by mechaflash; 03-22-2011 at 06:58 PM.
- 03-23-2011 #2
Telling us what the warning is might be useful.
His script rather creatively does the following;
Removes some files from /home/public
Looks for lines containing the string GB-1 in files under /usr/CC/DATA1/RPT/ that have been changed less than 24 hours ago, and then takes those matched strings (which are presumably filenames) and copies them to /home/public.... a slightly less insane way of accomplishing this in two lines would be....
Code:rm -f /home/public/ccnf* find /usr/CC/DATA/RPT -name "ccnf*" -ctime -1 -print | xargs fgrep -l "GB-1" | xargs -i cp -p {} /home/public
- 03-23-2011 #3Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
You're gonna laugh when you hear this -.- They didn't inform me that it happens only on specific days. The warning that is received is that the script can't remove ccnf* (not found) and that's because no data is being written over the weekend (they only receive the warning every Sunday and Monday morning =/)


Reply With Quote
