- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script ..
Operating System - HP-UX
1756989
Members
2572
Online
108858
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО01-11-2010 03:35 AM
тАО01-11-2010 03:35 AM
Re: script ..
rm $(ls -ltr | awk 'NR <= 4 { print $9 }')
>Duncan: I can think of a good reason not to use for loops in this manner
Because 4 is too small to bother? :-)
>Duncan: I can think of a good reason not to use for loops in this manner
Because 4 is too small to bother? :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 04:51 AM
тАО01-11-2010 04:51 AM
Re: script ..
>Because 4 is too small to bother? :-)
no actually because what if the filenames are _really_ long (or we have a lot more than 4 files - not valid for this example but a generic reason to avoid for loops) - we can run into the problem of exceeding the max line length or argument count for the shell.
instead of:
for x in
I am an HPE Employee
no actually because what if the filenames are _really_ long (or we have a lot more than 4 files - not valid for this example but a generic reason to avoid for loops) - we can run into the problem of exceeding the max line length or argument count for the shell.
instead of:
for x in
do
...
done
I would always do:
cat
- | while read x
do
...
done
(syntactically incorrect, but you get the gist)
that lesson learnt after debugging a script which deleted archive logs in a directory - it stopped working when there we more than 255 logs present...
Duncan
I am an HPE Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 08:50 PM
тАО01-11-2010 08:50 PM
Re: script ..
>Duncan: actually because what if the filenames are _really_ long (or we have a lot more than 4 files...) we can run into the problem of exceeding the max line length or argument count for the shell.
In both cases, you can't use a for-loop nor my $(). Typically 4 * N will always be less than 2 Mb.
>I would always do: while read x
>(syntactically incorrect
You mean evil cat incorrect. :-)
Yes, while read or xargs.
In both cases, you can't use a for-loop nor my $(). Typically 4 * N will always be less than 2 Mb.
>I would always do: while read x
>(syntactically incorrect
You mean evil cat incorrect. :-)
Yes, while read or xargs.
- Tags:
- evil cat
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP