![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to differentiate columns of a file in perl with no specific delimiter | Amiya Rath | Shell Programming and Scripting | 9 | 07-15-2008 12:51 AM |
| creating a delimiter string | satish@123 | Shell Programming and Scripting | 0 | 05-21-2008 05:38 AM |
| Parsing string | rolex.mp | UNIX for Dummies Questions & Answers | 3 | 02-20-2007 01:28 PM |
| String Parsing help | jasjot31 | UNIX for Dummies Questions & Answers | 5 | 09-27-2006 05:38 AM |
| split string with multibyte delimiter | azmathshaikh | Shell Programming and Scripting | 1 | 03-06-2005 06:50 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Parsing string using specific delimiter
Hi,
I'm wondering what is the best way to parse out a long string that has a specific deliminator and outputting each token between the delim on a newline? i.e. input text1,text2,text3,tex4 i.e. output text1 text2 text3 text4 |
|
||||
|
That's not really parsing, that's simple substitution.
Code:
tr , '\n' <input >output |
|
||||
|
Oh I can't believe I forgot about tr.
Although, this works, I can only get it to recognize a newline but can't combine with that a newline+few tabs? I also have a string that in the form of: variable = "data value" I have an extended sed to remove all instances of the double quotes, is there a on liner that'll grab the right hand side of the "equal" sign and only output the datavalue without the quotes. Thanks for your help. |
|
||||
|
This is in response to the original question, you said to use "tr" to add newline but I can't seem to get "tabs" to also be added?
So I get an output with a single tab, and the rest are not tabbed. Script: Code:
#!/bin/sh
A='text1,text2,text3'
echo -e "Output: \n\t${A}" | tr , '\n'
Code:
Output:
text1
text2
text3
Code:
Output:
text1
text2
text3
|
|
||||
|
This removes everything up to the first equals sign on every line:
Code:
sed -e 's/^[^=]*=//' file Code:
sed -e 's/,/\n\t\t/g' file |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|