- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How can I delimit a string and arrange them in row...
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-29-2002 01:08 AM
06-29-2002 01:08 AM
How can I delimit a string and arrange them in rows ??
I encounter a difficult in delimiting an unknow strings (i.e dynamica changes in length) and arrange them in a row format !!
E.g. I have a string like:
a, b, c, d, e, f, g, ....etc.
I would like to arrange them like:
a
b
c
d
e
f
g
.
.
.
etc.
I've try to write a simple script with while loop and awk ....but was in vain!! Any ideas?? Appreciate if you can help solve this problem.
Thanks,
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2002 01:58 AM
06-29-2002 01:58 AM
Re: How can I delimit a string and arrange them in rows ??
Try this:
echo "a, b, c, d, e, f"|tr -d " "|tr -s "," "\n"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2002 04:37 AM
06-29-2002 04:37 AM
Re: How can I delimit a string and arrange them in rows ??
If you wanted to preserve blanks (whitespace) between the comma-delimited fields, as in a person's name, drop the '-d " "' from the suggestion I made above:
# echo "a, b, c, d, e, f"|tr -s "," "\n"
Given a file of comma delimited fields, but with trailing whitespace, e.g. "my name ," then remove the *trailing* whitespace :
# cat myfile|tr -s "," "\n"|sed -e 's/[ \t]*$//'
For timming *leading* whitespace, e.g. " my name," :
# cat myfile|tr -s "," "\n"|sed -e 's/^[ \t]*//'
...and to trim both trailing and leading whitespace, e.g. " my name ," :
# cat myfile| cat /tmp/myfile |tr "," "\n"|sed -e 's/^[ \t]*//' -e 's/[ \t]*$//'
NOTE! In all the example above with { \t] type a "[", a space (blank), a TAB chararacter, and a "]".
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2002 06:36 AM
06-29-2002 06:36 AM
Re: How can I delimit a string and arrange them in rows ??
echo "a, b, c, d ..." | tr ',' ' ' | xargs -n1
Heiner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2002 12:02 AM
07-01-2002 12:02 AM
Re: How can I delimit a string and arrange them in rows ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2002 05:08 PM
07-05-2002 05:08 PM
Re: How can I delimit a string and arrange them in rows ??
Please forgive the syntax, I'm not currently at a terminal to test.
echo $string > string.file
counter=1
test_var=TEST
while [ ! -z $test_var ]
do
echo $test_var >> temp.file
test_var=`awk -F, '{print $'$counter'}' string.file`
let counter=$counter+1
done
Use cat to check the temp.file. The $counter in the awk statement may need double quotes.