-
- Forums
-
Blogs
- Alliances
- Around the Storage Block
- Behind the scenes @ Labs
- HPE Careers
- HPE Storage Tech Insiders
- Infrastructure Insights
- Inspiring Progress
- Internet of Things (IoT)
- My Learning Certification
- OEM Solutions
- Servers: The Right Compute
- Shifting to Software-Defined
- Telecom IQ
- Transforming IT
- Infrastructure Solutions German
- L’Avenir de l’IT
- IT e Trasformazione Digitale
- Enterprise Topics
- ИТ для нового стиля бизнеса
- Blogs
-
Quick Links
- Community
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Contact
- Email us
- Tell us what you think
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Enterprise.nxt
- Marketplace
- Aruba Airheads Community
-
Forums
-
Blogs
-
InformationEnglish
- 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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-02-2011 09:11 PM
01-02-2011 09:11 PM
I have a file with a bunch of e-mail addresses in it.
How do I display (or perform any other task) each and every e-mail address from this file ?
EMAIL=`cat eaccounts`
for ARG in "$EMAIL"
do
echo $ARG
done
Unfortunately the above method will print a list of e-mail addresses instead of one per time. Which proves that there is only one ARG which looks something lie this: user1@dom.com user2@dom.com user3@dom.com etc.
How do I make the script know there are multiple addresses in this file please ?
Regards
Peter
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-02-2011 09:47 PM
01-02-2011 09:47 PM
SolutionOn what?
uname -a
It's nice that at least one of us can see
what's in that file. It might be nicer if
_more_ than one of us could see what's in
that file.
> for ARG in "$EMAIL"
Did you try anything like, say:
for ARG in $EMAIL
?
If the items in the file are arranged one per
line, like, say:
$ cat em.dat
line 1
line 2
line 3
then a while-read loop could be used:
$ cat em.sh
#!/bin/sh
(
while read line ; do
echo "$line"
done
) < em.dat
$ ./em.sh
line 1
line 2
line 3
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-03-2011 08:56 AM
01-03-2011 08:56 AM
Re: script
(
while read line ; do
echo "$line"
done
) < em.dat
Worked for me.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-03-2011 12:15 PM
01-03-2011 12:15 PM
Re: script
And so would Steven's first suggestion of removing those quotes:
for ARG in $(< eaccounts); do
echo $ARG
done
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2019 Hewlett Packard Enterprise Development LP