- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Reading lines in a loop
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
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
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
тАО08-19-2002 08:45 AM
тАО08-19-2002 08:45 AM
I am trying to read line by line in for loop
Here is my section of netgroup file which has \ at the end
B132 (alderon.vdgc.com,-,) (alderon,-,) (babafett.vdgc.com,-,) (babafett,-,) (c3po.vdgc.com,-,) (c3po,-,) (chewie.vdgc.com,-,) (chewie,-,) (droid.vdgc.com,-,) (droid,-,) (dthstar1.vdgc.com,-,) (dthstar1,-,) (endor.vdgc.com,-,) (endor,-,)
while read line
do
echo "$line"
done < file_name
It will gives me all line without \ at the end.
How can I solve this?
Sachin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 08:47 AM
тАО08-19-2002 08:47 AM
Re: Reading lines in a loop
\\ will return a single \.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 09:22 AM
тАО08-19-2002 09:22 AM
Re: Reading lines in a loop
B132(alderon.vdgc.com,-,) (alderon,-,)(babafett.vdgc.com,-,) (babafett,-,).......
endor.vdgc.com,-,) (endor,-,)
B2000(venus.vdgc.com,-,) (venus,-,)(mars.vdgc.com,-,) (mars,-,).......
(rock.vdgc.com,-,) (rock,-,)
That way is more readable (that's how I got mine done).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 09:22 AM
тАО08-19-2002 09:22 AM
Re: Reading lines in a loop
It suppose to be
B132 (alderon.vdgc.com,-,) (alderon,-,) (babafett.vdgc.com,-,) (babafett,-,) (c3po.vdgc.com,-,) (c3po,-,) droid.vdgc.com,-,) (droid,-,)
And so on...
Rodney, I can't use \\ on netgroup file. I do not want to change original file to make my script work.
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 09:24 AM
тАО08-19-2002 09:24 AM
Re: Reading lines in a loop
B132
(alderon.vdgc.com,-,) (alderon,-,)
(babafett.vdgc.com,-,) (babafett,-,)
.......
endor.vdgc.com,-,) (endor,-,)
B2000
(venus.vdgc.com,-,) (venus,-,)
(mars.vdgc.com,-,) (mars,-,)
.......
(rock.vdgc.com,-,) (rock,-,)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 09:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 09:26 AM
тАО08-19-2002 09:26 AM
Re: Reading lines in a loop
#!/path2perl
open(INFILE, "
print $_;
}
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 09:26 AM
тАО08-19-2002 09:26 AM
Re: Reading lines in a loop
It suppose to be
B132 "\"
(alderon.vdgc.com,-,) (alderon,-,) "\"
(babafett.vdgc.com,-,) (babafett,-,) "\"
(c3po.vdgc.com,-,) (c3po,-,) "\"
droid.vdgc.com,-,) (droid,-,) "\"
And so on...
So third try with double quote around my \\.
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 09:32 AM
тАО08-19-2002 09:32 AM
Re: Reading lines in a loop
That works.
SK I have my netgroup file same way as you trying to describe. Harry no perl this time.
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 09:32 AM
тАО08-19-2002 09:32 AM
Re: Reading lines in a loop
Have a look at the man pages for 'read'. The '-r' option causes the backslach "\" character not to be treated in any special
way. That is, to consider each backslash to be part of the input line.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 09:35 AM
тАО08-19-2002 09:35 AM
Re: Reading lines in a loop
Can you try this? It should work, assuming that the "\" is at the end of the line if any. Otherwise, you can try again without the "$" sign in the sed command.
cat file_name | sed 's:\\$:\\\\:' | while read line
do
echo "$line"
done
Hai