Please help replace character command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help replace character command
# 1  
Old 12-16-2009
Please help replace character command

hi i have log :

Quote:
528111500205609F'TBCD 359733008174600F'TBCD 196738835662'TBCD 183355713230'TBCD
528111500100961F'TBCD 357621009740840F'TBCD 196738607623'TBCD 183355713230'TBCD
528111500003745F'TBCD 352259013637400F'TBCD 196738921095'TBCD 183355713230'TBCD
528111500100961F'TBCD 357621009740840F'TBCD 196738607623'TBCD 183355713230'TBCD
528111500180328F'TBCD 352278011725250F'TBCD 196737141141'TBCD 183396003964'TBCD
528111500205609F'TBCD 359733008174600F'TBCD 196738835662'TBCD 183355713230'TBCD
528111500205609F'TBCD 359733008174600F'TBCD 196738835662'TBCD 183355713230'TBCD
528111500195038F'TBCD 358358007960300F'TBCD 196738644278'TBCD 183355713230'TBCD
528111500210829F'TBCD 355664004587510F'TBCD 196738698876'TBCD 183355713230'TBCD
i want remove some char become like this:

Quote:
528111500205609 35973300817460 6738835662 183355713230
528111500100961 35762100974084 6738607623 183355713230
528111500003745 35225901363740 6738921095 183355713230
528111500100961 35762100974084 6738607623 183355713230
528111500180328 35227801172525 6737141141 183396003964
528111500205609 35973300817460 6738835662 183355713230
528111500205609 35973300817460 6738835662 183355713230
528111500195038 35835800796030 6738644278 183355713230
528111500210829 35566400458751 6738698876 183355713230
anybody can help me ?
# 2  
Old 12-16-2009
cat file | sed "s:'TBCD::g"
# 3  
Old 12-16-2009
i think that command only can remove this 'TBCD
how about this line.. " 0F'TBCD 19 " ??

i mean the column 1 2 3 there are a bit different in the result

Last edited by justbow; 12-16-2009 at 03:10 AM..
# 4  
Old 12-16-2009
try:
Code:
sed "s/\(0F\|F\)\?'TBCD//g" infile

-or-

Code:
sed -r "s/(0F|F)?'TBCD//g" infile

# 5  
Old 12-16-2009
how about the "19" in column 3 ??
# 6  
Old 12-16-2009
Code:
cut -c1-15,22-37,44,47-56,61-74 infile

You can also do it with sed but since you need to remove characters at fixed positions cut is the more obvious choice IMO.
Code:
sed 's/..TBCD//1;s/...TBCD 19/ /1;s/.TBCD//g' infile


Last edited by Scrutinizer; 12-16-2009 at 03:51 AM..
# 7  
Old 12-16-2009
Code:
gawk '{gsub(/\047TBCD/,"");gsub(/^19/,"",$3)}{print}' file


Last edited by ichigo; 12-16-2009 at 06:24 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Replace certain character at specific place with related character

hello i have file with 100k records and each one has certain value that starts at 28th column and certain value that starts at 88th column e.g. 1st file <25>1234567 ..... <88> 8573785485 i have aditional file with values which are related to value that starts at 88th column of the... (1 Reply)
Discussion started by: dell1520
1 Replies

2. Shell Programming and Scripting

Find character and Replace character for given position

Hi, i want find the character '-' in a file from position 284-298, if it occurs i need to replace it with 'O ' for the position in the file. How to do that using SED command. thanks in advance, Sara (9 Replies)
Discussion started by: Sara183
9 Replies

3. Shell Programming and Scripting

sed command to replace a character at last

Hi All, I have a file having one line only. It is like trapsess:inform|10.232.167.18|1|1|50|25|0|0|0|5|1|1|78|0037| I want to replace the numbers in last two columns by As. It should look like trapsess:inform|10.232.167.18|1|1|50|25|0|0|0|5|1|1|AA|AAAA| Please, suggest me any shell... (12 Replies)
Discussion started by: mukeshbaranwal
12 Replies

4. Shell Programming and Scripting

Replace '$' with no character using tr command

Hi All, Need your help urgently. since '$' comes at the end of the line i want to remove '$' using tr command: file: 111111|.11|.00$ 222222|2.22|.00$ 333333|.33|.00$ 444444|.44|.00$ Thanks in Advance (7 Replies)
Discussion started by: HemaV
7 Replies

5. Shell Programming and Scripting

Replace multiple occurances of same character with a single character.

Hi all, Greetings, I have the following scenario, The contents of main file are like : Unix|||||forum|||||||||||||||is||||||the||best so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it And i need the output in the following form: Unix=forum=is=the=best so=be=on=it ... (3 Replies)
Discussion started by: dipanchandra
3 Replies

6. Shell Programming and Scripting

In Sed how can I replace starting from the 7th character to the 15th character.

Hi All, Was wondering how I can do the following.... I have a String as follows "ACCTRL000005022RRWDKKEEDKDD...." This string can be in a file called tail.out or in a Variable called $VAR2 Now I have another variable called $VAR1="000004785" (9 bytes long), I need the content of... (5 Replies)
Discussion started by: mohullah
5 Replies

7. Shell Programming and Scripting

replace two character strings by two variables with sed command

Hello, I want to writte a script that replace two character strings by two variables with the command sed butmy solution doesn't work. I'm written this: sed "s/TTFactivevent/$TTFav/g && s/switchSLL/$SLL/g" templatefile. I want to replace TTFactivevent by the variable $TTFav, that is a... (4 Replies)
Discussion started by: POPO10
4 Replies

8. Shell Programming and Scripting

script command to replace character

Hi, i have log like this : Actually i want to change the time stamp, and the rule is like this : and My script is like this : I know the script will loop and loop again after 07:00 like this: Can somebody help me ?? Thanks in advance.. (5 Replies)
Discussion started by: justbow
5 Replies

9. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies

10. UNIX for Dummies Questions & Answers

Command to replace character

I've been googling for the following for the past few weeks several times, but haven't yet come across something that I could easily grasp. Can someone point me in the right direction please? I'm trying to replace a character in file names, i.e. the character is a period, and I want to replace... (5 Replies)
Discussion started by: HLee1981
5 Replies
Login or Register to Ask a Question