- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Question about James/Victor's Script???
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2000 11:50 AM
08-21-2000 11:50 AM
Question about James/Victor's Script???
Thanks a lot James/Victor...
Just a quick question for you James. In the last response you answered I noticed that in the following line -
FILES=`echo $FILES | cut -f1-$N -d " "` #...list's
in the cut portion you have -d. What does that do? If you get a chance what exactly does this whole line do?
I really like the logic that you put into this. I will have to learn this a lot better.
One other question is why do you have the head statement by itself above the rm?
Does it not need any options? Look forward to hear from you. Thanks
MYDIR=/tmp/mylog* #...whatever...
FILES=`ls -t $MYDIR` #...collect by mod time
COUNT=`echo $FILES | wc -w` #...get how many
if (( COUNT < 100 ))
then
exit 0
fi
let N=COUNT-100 #...keep 100 of them...
FILES=`echo $FILES | cut -f1-$N -d " "` #...list's
head
rm $FILES
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2000 12:01 PM
08-21-2000 12:01 PM
Re: Question about James/Victor's Script???
FILES=`echo $FILES | cut -f1-$N -d " "`
The variable FILES is updated with the result of itself after 'cut'ting fields one (1) through the value of N. The cut operation's delimiter (d) is the blank character (" ").
Check the manual pages for cut. Do:
# man cut
Victor's solution is a good one too, and he and other can be awarded points for their responses to your queries, too.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2000 12:07 PM
08-21-2000 12:07 PM
Re: Question about James/Victor's Script???
Thanks for the script... Should I keep the head statement in there? It's by itself with no parameters just before you do the rm.
Sorry for all the questions but it has helped me a great deal....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2000 12:11 PM
08-21-2000 12:11 PM
Re: Question about James/Victor's Script???
Looks like he's getting a list of all the files in MYDIR and then using the N variable to count the total number of files in the list and then truncate the list to only include the last N files in the list, where N is the number of files OVER 100.
FILES=`echo $FILES | cut -f1-$N -d" "`
This line echos the current value of FILES and cuts out the first N (-f1-$N) files separated by a space delimiter (-d" ") and sets them to be the new value of FILES. The script then removes these files, just leaving the last 100 files in MYDIR.
--Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2000 12:15 PM
08-21-2000 12:15 PM
Re: Question about James/Victor's Script???
Thanks for the help on describing the script... Should I keep the head statement in there? It's by itself with no parameters just before you do the rm. Normally I have seen parameters used with it in the past.
That's the last of my questions once I have it figured out... Thanks for all your help...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2000 12:20 PM
08-21-2000 12:20 PM
Re: Question about James/Victor's Script???
No. You don't need the head statement. I'm actually a little curious what that's doing in there. ;)
--Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2000 12:32 PM
08-21-2000 12:32 PM
Re: Question about James/Victor's Script???
--Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2000 12:42 PM
08-21-2000 12:42 PM
Re: Question about James/Victor's Script???
Scott's comments are absolutely on target. He descibed for you perfectly my method of attack. The 'head' should not be there -- it was part of a different solution provided by Victor. Thanks, Scott.
...JRF...