SORT CARD for replacing characters.


 
Thread Tools Search this Thread
Operating Systems Linux SORT CARD for replacing characters.
# 1  
Old 10-24-2011
Java SORT CARD for replacing characters.

Hi all,

Am new to linux.
Please advise me how to program a SORT CARD that relaces characters.
For e.g.,

201115456563040gh879245k
20112450911804Ads559672p
20112276533504{tg090669d
201123776591040ra008792y
20114452611704{wq47544q

In the above data, I need to relace all { to 0 (am talking about the bold part).

Kindly advise me a sort card for the above.
# 2  
Old 10-24-2011
Code:
$ sed 's,{,0,g' infile

---------- Post updated at 04:10 PM ---------- Previous update was at 04:05 PM ----------

in nawk ..
Code:
$ nawk '{sub(/{/,"0")};1' infile

This User Gave Thanks to jayan_jay For This Post:
# 3  
Old 10-24-2011
Do you want to replace all the '{' characters with '0', or replace the 3 bold character columns with something else? (or give some example output)
# 4  
Old 10-24-2011
Java

I want to replace only the { to 0. Like..


20112276533504{tg090669d

the o/p generated for the above would be
201122765335040tg090669d

I have bolded the three letters because the three characters are on my notice. It may be the below case also...

201122765335{40tg090669d or
2011227653350{0tg090669d or
20112276533504{tg090669d.

But my output will replace the { to 0.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed replacing specific characters and control characters by escaping

sed -e "s// /g" old.txt > new.txt While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Discussion started by: ijustneeda
11 Replies

2. UNIX for Dummies Questions & Answers

Replacing hex characters

I have the following file consisting of dates and sample measurements: 05��Oct��2010 1.31�� 06��Oct��2010 1.32�� 07��Oct��2010 1.31�� The hex characters are \xc2\xa0 in sequence. I have tried to remove the characters as follows: sed -i '' -e 's/\xc2\xa0//g' file.dat and as follows... (6 Replies)
Discussion started by: figaro
6 Replies

3. UNIX for Dummies Questions & Answers

Replacing multiple characters

I have a file as follows ggsnApnDownlinkBytes.X ggsnApnDownlinkDrops.X ggsnApnDownlinkPackets.X ggsnApnName.X ggsnApnUplinkBytes.X ggsnApnUplinkDrops.X ggsnApnUplinkPackets.X ggsnApnDownlinkBytes.Y ggsnApnDownlinkDrops.Y ggsnApnDownlinkPackets.Y ggsnApnName.Y ggsnApnUplinkBytes.Y... (7 Replies)
Discussion started by: rob171171
7 Replies

4. Shell Programming and Scripting

Replacing text/characters in vi

ok, so i have the following text to replace but it's not working. can someone please help me out: :%s~awk '// {split($2,s,",");a=$1 FS s} /-/ {b=a} END{print b}'~tail -1~g I want to replace the entire awk command with tail -1. thanks (7 Replies)
Discussion started by: SkySmart
7 Replies

5. Shell Programming and Scripting

Replacing characters

Hi fellow experts, I have a question for you. Data looks like: 00877,05/13/2010,PBO,P,0000708331,518 00877,05/13/2010,PBO,P,0000708331,519 ... ... 00877,05/13/2010,PBO,P,0000708331,2103 00877,05/13/2010,PBO,P,0000708331,2104,etc,etc Basically I have to replace 518,519,2103,2104,... (4 Replies)
Discussion started by: Devski123
4 Replies

6. Shell Programming and Scripting

Replacing Characters with |

Hi All, example data.log 526569346 66815531961 09 526569346 66815531961 09 526569346 66815531961 09 526569346 66815531961 09 526569346 66815531961 09 I want like this to 526569346|66815531961|09 526569346|66815531961|09... (4 Replies)
Discussion started by: ooilinlove
4 Replies

7. Shell Programming and Scripting

Replacing Characters

Hi All, I have a file which is delimeted with the character '. i need to replace this character with the same character and also a new line. Can anyone please help me with the tr command for this. Many thanks Karan (11 Replies)
Discussion started by: karansachdeva
11 Replies

8. Shell Programming and Scripting

replacing characters

hi all I have a file that has sone spaces in start then / at last. i want to get rid of this. how to do? eg. 11414/ 49878/ 27627/ I WANT THE FILE AS 11414 49878 27627 PLEASE HELP (3 Replies)
Discussion started by: infyanurag
3 Replies

9. UNIX for Dummies Questions & Answers

replacing characters

Hi, I have a script for replacing bad characters in filenames for f in *; do mv $f `echo $f | tr '+' '_'` done; this replaces + for _ But I need to replace all bad characters ? / % + to _ Pls how can i do this in one script ? (3 Replies)
Discussion started by: palmer18
3 Replies

10. UNIX for Dummies Questions & Answers

replacing characters in order to sort

hi, i want to rename all the file names in order so that they can be sorted later. For example, my filenames are like path\1, path\2...path\10, path\11. But when I sort them, it sorts by the first number, so path\1 gets sorted with path\10. I'm guessing the best way to do this is to rename... (5 Replies)
Discussion started by: gammaman
5 Replies
Login or Register to Ask a Question