- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell 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
06-06-2003 12:18 AM
06-06-2003 12:18 AM
Shell script
as below
for entry in `cat /tmp/sa`
do
echo $entry
done
The content of file /tmp/sa is
08:06:03 10 20 10 20
09:07:03 20 30 20 20
10:07:03 20 10 20 10
However when I do echo $entry in script
it is showing single field 08:06:03 instead
of entire line
08:06:03 10 20 10 20
Is there any Ouput field separator ins shell
so that my for loop variable fetches
a line
Regards
Nitin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 12:22 AM
06-06-2003 12:22 AM
Re: Shell script
IFS=""
Then it works.
IFS=""
for entry in $(cat /tmp/sa)
do
echo $entry
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 12:23 AM
06-06-2003 12:23 AM
Re: Shell script
you can change you script like this
while read TEXT
do
echo $TEXT
done << /tmp/sa
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 12:25 AM
06-06-2003 12:25 AM
Re: Shell script
Easiest way is
-------------
cat /tmp/sa|while read line
do
echo $line
sleep 3
done
----------------
HTH
-tamil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 01:44 AM
06-06-2003 01:44 AM
Re: Shell script
in order to get all arguments from the line, you need to use quotes, e.g.:
for entry in "`cat /tmp/sa`"
do
echo "$entry"
done
a better looking notation with same effect:
for entry in "$(cat ./infile)"
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 01:58 AM
06-06-2003 01:58 AM
Re: Shell script
while read STR
do
echo $STR
done < /tmp/sa
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 03:13 AM
06-06-2003 03:13 AM
Re: Shell script
cat file |
while read line
do
echo $line
done
you could also do it like this if you wanted only specific fields:
cat file |
whle read a b c d e
do
echo $a $b $e
done