|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Concatenating strings to "tr" command output
Hi All, Please help me in forming command for the following scenario. My input string (msg)is \'01\',\'02\',\'03\',\'04\',\'05\',\'06\' , i have removed \ and ' using Code:
echo $msg|tr -d '\\'|tr -d "'" which gave me output as 01,02,03,04,05,06. I am half done here. Now i want to append single quotes at the beginning and ending of this out , with in the same command. I tried below command Code:
echo $msg|tr -d '\\'|tr -d "'"|print "'"$msg"'" . But i am getting output as ''01','02','03','04','05','06''. Please help me to get the output in below format '01,02,03,04,05,06'. Thanks in advance |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Code:
echo $msg|sed "s/'//g" |
|
#4
|
||||
|
||||
|
Code:
msg="\'01\',\'02\',\'03\',\'04\',\'05\',\'06\'" echo "$msg"|sed "s:\\\'::g;s/^/'/;s/$/'/" producing Code:
'01,02,03,04,05,06' |
| The Following User Says Thank You to elixir_sinari For This Useful Post: | ||
chpsam (02-12-2013) | ||
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Code:
echo "01,02,03,04,05,06"|sed -e "s/^/'/g" -e "s/$/'/g" Last edited by Franklin52; 02-12-2013 at 08:48 AM.. Reason: Please use code tags for data and code samples |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Thanks all for the replies. You solved my problem
![]() Just wanted to check if i can achieve it without using sed or awk ? |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
See my earlier reply.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| finding the strings beween 2 characters "/" & "/" in .txt file | Behrouzx77 | Shell Programming and Scripting | 10 | 10-25-2012 09:48 AM |
| awk command to replace ";" with "|" and ""|" at diferent places in line of file | shis100 | Shell Programming and Scripting | 7 | 03-16-2011 08:59 AM |
| "Join" or "Merge" more than 2 files into single output based on common key (column) | Katabatic | Shell Programming and Scripting | 1 | 05-20-2010 11:41 AM |
| Explanation of "total" field in "ls -l" command output | proactiveaditya | UNIX for Dummies Questions & Answers | 1 | 04-18-2010 01:40 AM |
| Debian: doubt in "top" %CPU and "sar" output | jaduks | Debian | 0 | 09-12-2007 08:05 AM |
|
|