- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- scripting - running through a list
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
тАО02-04-2007 01:07 PM
тАО02-04-2007 01:07 PM
HPux 11.11 v1.
This is going to be really basic,but for some reason I am just not able to get it.!
I have a file of names (first and second name per line).
I want to take each line and run a command on it...
file1 =
firstname1 lastname1
firstname2 lastname2
I want to do something like:
for i in `cat file1`
do
echo $i
done
and $i would echo back with
firstname1 lastname1
firstname2 lastname2
at the moment I am getting a list like:
firstname1
lastname1
firstname2
lastname2
I know this ridiculously easy.... please someone help
thanks Maria
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2007 02:27 PM
- Tags:
- while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2007 02:30 PM
тАО02-04-2007 02:30 PM
Re: scripting - running through a list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2007 02:30 PM
тАО02-04-2007 02:30 PM
Re: scripting - running through a list
do
echo "Name: ${NAME}"
done
If you want firstname and lastname as separate variables then:
cat file1 | while read FNAME LNAME
do
echo "First Name: ${FNAME} Last name: ${LNAME}"
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2007 02:49 PM
тАО02-04-2007 02:49 PM
Re: scripting - running through a list
Thankyou both Denver and yourself, both methods worked for me.
Maria
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2007 01:20 PM
тАО02-05-2007 01:20 PM
Re: scripting - running through a list
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2007 01:34 PM
тАО02-05-2007 01:34 PM
Re: scripting - running through a list
Maria
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2007 02:51 PM
тАО02-05-2007 02:51 PM
Re: scripting - running through a list
xargs -n2 echo < file1
-n2 says to put only 2 arguments on the echo command. If you wanted to have more text with the echo, you would have to execute a command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2007 08:47 PM
тАО02-05-2007 08:47 PM
Re: scripting - running through a list
cat file | while read line ; do
echo $line
done
-Eric