- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script Output
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
11-12-2009 01:41 AM
11-12-2009 01:41 AM
Can you help below Please? Using sed command, How to convert the input as "adhn4807, adhn5326, adhn5327, adhn5328, adhn5333," to the output below?
adhn4807
adhn5326
adhn5327
adhn5328
adhn5333
Thanks alot in advance.
Regards,
Negara
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2009 02:28 AM
11-12-2009 02:28 AM
Re: Script Output
I am not sure about sed, but following script runs well according to you:
#################
#!/usr/bin/sh
VAR="adhn4807, adhn5326, adhn5327, adhn5328, adhn5333,"
for A in `echo $VAR | awk -F"," '{print $1,$2,$3,$4,$5}'`
do
echo $A
done
#################
Hope this helps..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2009 02:44 AM
11-12-2009 02:44 AM
Re: Script Output
Need to convert the output to:
adhn4807
adhn5326
adhn5327
adhn5328
adhn5333
...
...
...
etc (many more)
Regards,
Negara
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2009 03:17 AM
11-12-2009 03:17 AM
Re: Script Output
You can put the server names in a file "ex1".
Then run following command:
# awk -F", " '{ for (i = 1; i <= NF; i++) print $i}' ex1
adhn4807
adhn5326
adhn5327
adhn5328
adhn5333
Where:
#more ex1
adhn4807, adhn5326, adhn5327, adhn5328, adhn5333
Hope this will be of some help..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2009 03:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2009 05:18 AM
11-12-2009 05:18 AM
Re: Script Output
Your data shows that there are whitespaces following the commas. To eliminate these and produce the output you showed, use a one-process Perl instead of pipes with 'tr' and/or 'sed':
# perl -pe 's/,\s*/\n/g' file
(or)
# X="adhn4807, adhn5326, adhn5327, adhn5328, adhn5333"
# echo ${X}|perl -pe 's/,\s*/\n/g'
This code reads your file globally substituting a newline character for any comma with or without an optional whitespace (\s) following it.
If you are using a GNU 'sed' then this would work too:
# sed -e "s/,[ ]*/\n"/g file
Unfortunately, the standard HP-UX 'sed' doesn't support this syntax.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2009 05:34 AM
11-12-2009 05:34 AM
Re: Script Output
for word in $(sed 's/,//g' file); do
print $word
done
With vi you can change comma to newlines:
:%s/, /^V/g
(That's a control-V.)
Then a cleanup of comma without a space.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2009 05:36 AM
11-12-2009 05:36 AM
Re: Script Output
With vi you can change comma to newlines:
:%s/, /^V^M/g
(That's a control-V followed by a enter.)
Then a cleanup of comma without a space.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2009 08:31 AM
11-12-2009 08:31 AM
Re: Script Output
Thanks alot for your help. Got the answer. Appreciate your help.
Best Regards,
Negara