| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

05-09-07, 19:43
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 21
|
|
|
sed/awk
|
|
i have file containing lines such as
Char(Month(L.prd_cvrg_end_dt)) =
STRIP(substr(V_MON_YR,1,2),L,'0')
AND Char(Year(L.prd_cvrg_end_dt))
which i need to change as:
Char(Month(L.prd_cvrg_end_dt)) =
STRIP(substr(V_MON_YR,1,2),'L','0')
AND Char(Year(L.prd_cvrg_end_dt))
how do i get this done.
i.e. change only the character ,L, to ,'L',
i attempted using sed/awk it looks like i have an error.
|
Last edited by usc; 05-09-07 at 19:51.
|

05-10-07, 04:26
|
|
Registered User
|
|
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
|
|
Code:
cat in-file | sed -e 's/,L,/,'L',/g' > out-file
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
|
|

05-10-07, 12:48
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 21
|
|
|
|
the single quote didn't make the changes.
tried double quote(") instead of single quote('), it works
cat t1 | sed -e "s/,L,/,'L',/g" > t2
|
Last edited by usc; 05-10-07 at 12:54.
|

05-11-07, 07:39
|
|
Registered User
|
|
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
|
|
yeah single quote will cause an error
i.e.
cat in-file | sed -e 's/,L,/,'
then L
then ',/g' > out-file
I'm not 100% on sed but i would imagine you could delimit that to give you :
cat in-file | sed -e 's/,L,/,\'L\',/g' > out-file
|
|

05-11-07, 16:37
|
|
Registered User
|
|
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
|
|
Right. Escaping the nested single quotes will work. This is not an sed thing but rather the shell takes care of the escaping.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
|
|

05-31-07, 00:05
|
|
Registered User
|
|
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
|
|
Quote:
|
Originally Posted by usc
the single quote didn't make the changes.
tried double quote(") instead of single quote('), it works
cat t1 | sed -e "s/,L,/,'L',/g" > t2
|
...and why exactly do you need a 'cat'?
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|