- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Help with a 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
Discussions
Discussions
Forums
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
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
тАО05-29-2008 10:51 AM
тАО05-29-2008 10:51 AM
Re: Help with a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2008 10:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2008 12:05 PM
тАО05-29-2008 12:05 PM
Re: Help with a script
thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2008 02:36 AM
тАО05-30-2008 02:36 AM
Re: Help with a script
(You shouldn't be using cat, that's evil. :-)
There are two basic ways to handle files with files. Either use while, as JRF said:
while file; do
...
done < file
Or if a "limited" number that will fit in a shell command line, you can use for (an improvement of Steven's case):
for file in $(< file); do
...
done
Note: No cats needed.
As a coding style, unless your other shell scripts need these variables, you shouldn't export them:
DATE=$(date '+%Y%m%d');export DATE
TIME=$(date '+%H%M%S');export TIME
And if you using a real shell, you can use the export command directly:
export FOO=bar
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2008 03:56 AM
тАО05-30-2008 03:56 AM
Re: Help with a script
As Dennis noted, 'cat's can be evil.
Well-behaved (written) Unix filters will read files passed as commandline arguments, or take their input from STDIN as from a pipe's output.
Thus, when someone writes (variously):
# cat file | awk ...
# cat file | grep ...
...they are creating a needless extra process and wasting I/O. The 'cat' process reads a file and writes each line of output which is then *read* again by another process only to filter and *write* something. Instead, one should write:
# awk '{ ... }' file
# grep whatever file
Regards!
...JRF... [ who happens to like cats (as animals) ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2008 05:03 AM
тАО05-30-2008 05:03 AM
Re: Help with a script
Hey. Don't blame me for that "cat". I was
only offering an illustration of how the
previous suggestion actually _does_ work
(with the right punctuation). As I said, "It
is possible to read names from a file, but
this is not one of the ways." The one of
those ways which I'd prefer is a while-read
like that suggested by Mr. Ferguson, which
allows more flexible processing more easily.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2008 07:29 AM
тАО05-30-2008 07:29 AM
Re: Help with a script
I like to use "set -x" at the begining of scripts and in functions while testing. It helps to debug... Just thought it might help.
Tommy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2008 07:34 AM
тАО05-30-2008 07:34 AM
Re: Help with a script
- « Previous
-
- 1
- 2
- Next »