Results 1 to 4 of 4
Hi,
I am really bad in sed commands. While I am trying to improve on this.
I have following list in a file <filename>:
AB_900_CDE_PQR_XY_0 0
AB_900_CDE_PQR_XY_1 0
AB_900_CDE_PQR_XY_2 0
...
- 05-20-2009 #1Just Joined!
- Join Date
- Nov 2006
- Posts
- 36
help with sed
Hi,
I am really bad in sed commands. While I am trying to improve on this.
I have following list in a file <filename>:
AB_900_CDE_PQR_XY_0 0
AB_900_CDE_PQR_XY_1 0
AB_900_CDE_PQR_XY_2 0
AB_900_CDE_PQR_XY_3 0
AB_900_CDE_PQR_XY_4 0
AB_900_CDE_PQR_XY_5 0
AB_900_CDE_PQR_XY_6 0
AB_900_CDE_PQR_XY_7 0
AB_900_CDE_PQR_XY_8 0
AB_900_CDE_PQR_XY_9 0
I want all '0' values to be replaced by 1.
AB_900_CDE_PQR_XY_0 1
AB_900_CDE_PQR_XY_1 1
AB_900_CDE_PQR_XY_2 1
AB_900_CDE_PQR_XY_3 1
AB_900_CDE_PQR_XY_4 1
AB_900_CDE_PQR_XY_5 1
AB_900_CDE_PQR_XY_6 1
AB_900_CDE_PQR_XY_7 1
AB_900_CDE_PQR_XY_8 1
AB_900_CDE_PQR_XY_9 1
Thanks for your help.
- 05-21-2009 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
Code:sed 's/0$/1/' file
- 05-25-2009 #3Just Joined!
- Join Date
- Nov 2008
- Posts
- 6
Help with SED
I am very much a green pea as far as scripting and SED are concerned.
I have managed with the assistance of a few people managed to get toget the following SED utilisation. Please do not laugh, I am sure that there is a better way to do this but I am only trying.
sed "s/D'A/D\''A/g" test > output1
sed "s/D'E/D\''E/g" output1 > output2
sed "s/D'U/D\''U/g" output2 > output3
sed "s/D'O/D\''O/g" output3 > output4
sed "s/D'I/D\''I/g" output4 > output5
sed "s/D'H/D\''H/g" output5 > output6
sed "s/L'E/L\''E/g" output6 > output7
sed "s/L'H/L\''H/g" output7 > output8
sed "s/d'a/d\''a/g" output8 > output9
sed "s/d'e/d\''e/g" output9 > output10
sed "s/d'u/d\''u/g" output10 > output11
sed "s/d'o/d\''o/g" output11 > output12
sed "s/d'i/d\''i/g" output12 > output13
sed "s/d'h/d\''h/g" output13 > output14
sed "s/l'e/l\''e/g" output14 > output15
sed "s/l'h/l\''h/g" output15 > output16
The issue that I have is I received text files that have french and spanish character sets and they have various possibilities in their naming convensions. For example.
d'animaux
I am looking for a way in which to bulk escape that with
d''animaux.
Now the script that I have above works great, but my issue is that there are various different ways in which this is used.
The possibilities are
d'animaux
D'Animaux
d'Animaux
D'animaux
So I am looking for the switch in SED that will ignore the characterset. It will not be detered by caps or small letters, it will just go about and make the required cahanges.
Then somehting that I have just thought about is, I am sure that I can place all the commands in one line. I really appreciate any help and advice on resolving this issue.
Thanks in advance
Lawrence
- 05-27-2009 #4Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
try this:
or with case insensitive option:Code:sed -e "s/\([dD]\)'\([aAeEiIoOuUhH]\)/\1\"\2/g" -e "s/\([lL]\)'\([eEhH]\)/\1\"\2/g" test
Code:sed -e "s/\(d\)'\([aeiouh]\)/\1\"\2/ig" -e "s/\([l]\)'\([eh]\)/\1\"\2/ig" data


Reply With Quote