![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem with dd command or maybe AFS problem | Anta | Shell Programming and Scripting | 0 | 08-25-2006 07:10 AM |
| SSH Problem auth problem | budrito | UNIX for Advanced & Expert Users | 1 | 03-17-2004 07:12 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
sed problem
Hi All,
I am having a text file say xyz which I convert into a file such that all the lines in that xyz file should have a “ on both the side of each line and \r and \n xyz which need to be converted: ============================= *%EFILocal [pdl_postscript:postscript] *%EFILocal [pdl_pcl:pcl] *%EFILocal [pdl_pjl:pjl] *%EFILocal [pdl_pdf:pdf] *%EFILocal [pdl_passthru:passthru] *%EFILocal [pdl_text:text] ================================ Converted file: say abc ============================ "*%EFILocal [pdl_postscript:postscript]\r\n" "*%EFILocal [pdl_pcl:pcl]\r\n" “\r\n” "*%EFILocal [pdl_pjl:pjl]\r\n" "*%EFILocal [pdl_pdf:pdf]\r\n" "*%EFILocal [pdl_passthru:passthru]\r\n" "*%EFILocal [pdl_text:text]\r\n" “\r\n” "*%EFILocal [pdl_tiff:tiff]\r\n" "*%EFILocal [pdl_xwd:xwd]\r\n" I use the sed utility and did the following: cat xyz | sed -e 's/\(.*\)$/"\1\\r\\n"/' | tr -d "\r" > abc But it is not helping for all the lines. For some lien it is working and for some line it is not working at all. For some line it is not feeding " in the begining of the line. Regards Gauri Agrawal Last edited by Perderabo; 12-12-2005 at 03:55 AM. Reason: Disable smilies for readability |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Your command should work. Can you give some cases in which your command is not working? Add the anchor symbol and try again
Code:
sed -e 's/^\(.*\)$/"\1\\r\\n"/' xyz | tr -d "\r" |
|
#3
|
|||
|
|||
|
thanks for the quick reply
actuly the following the line *%EFILocal [invisible_yes:S\x92] but when copy past only this line put in anothe file and then run sed, it works.. Can u please tell me how to add the anchor symbol. I guess it might be the problem Thanks & Regards Gauri Agrawal |
|
#4
|
||||
|
||||
|
Quote:
Code:
sed -e 's_.*_"&\\r\\n"_g' xyz |
|
#5
|
||||
|
||||
|
Quote:
Could you please try Vino's solution. "^" is the anchor symbol which matches the pattern in the beginning of the line. Code:
sed -e 's_.*_"&\\r\\n"_g' xyz |
|
#6
|
|||
|
|||
|
Hi Vino,
It has worked...can you please explain me if time permit u otherwise i will try to understand by my own as at least i got the solution. Thanks Again Regards Gauri |
|
#7
|
||||
|
||||
|
Quote:
Force of habit ! |
||||
| Google The UNIX and Linux Forums |