Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Please help replace character command

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-16-2009   -   Original Discussion by justbow
justbow justbow is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 28 October 2017, 6:52 AM EDT
Posts: 90
Thanks: 15
Thanked 1 Time in 1 Post
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 ?
Sponsored Links
    #2  
Old Unix and Linux 12-16-2009   -   Original Discussion by justbow
anand_bh anand_bh is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 29 October 2015, 2:33 PM EDT
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
cat file | sed "s:'TBCD::g"
Sponsored Links
    #3  
Old Unix and Linux 12-16-2009   -   Original Discussion by justbow
justbow justbow is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 28 October 2017, 6:52 AM EDT
Posts: 90
Thanks: 15
Thanked 1 Time in 1 Post
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 Unix and Linux 12-16-2009   -   Original Discussion by justbow
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 18 November 2017, 7:00 PM EST
Location: Amsterdam
Posts: 11,618
Thanks: 516
Thanked 3,380 Times in 2,979 Posts
try:

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

-or-


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

Sponsored Links
    #5  
Old Unix and Linux 12-16-2009   -   Original Discussion by justbow
justbow justbow is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 28 October 2017, 6:52 AM EDT
Posts: 90
Thanks: 15
Thanked 1 Time in 1 Post
how about the "19" in column 3 ??
Sponsored Links
    #6  
Old Unix and Linux 12-16-2009   -   Original Discussion by justbow
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 18 November 2017, 7:00 PM EST
Location: Amsterdam
Posts: 11,618
Thanks: 516
Thanked 3,380 Times in 2,979 Posts

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..
Sponsored Links
    #7  
Old Unix and Linux 12-16-2009   -   Original Discussion by justbow
ichigo ichigo is offline
Ghostdog (Read Only)
 
Join Date: Dec 2009
Last Activity: 19 December 2009, 6:21 AM EST
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts

Code:
gawk '{gsub(/\047TBCD/,"");gsub(/^19/,"",$3)}{print}' file


Last edited by ichigo; 12-16-2009 at 06:24 AM..
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Command to parse a word character by character girish.raos Shell Programming and Scripting 6 09-03-2009 04:18 AM
script command to replace character justbow Shell Programming and Scripting 5 07-17-2009 06:15 AM
replace a character with another character satish@123 Shell Programming and Scripting 8 05-13-2009 04:04 PM
read in a file character by character - replace any unknown ASCII characters with spa raghav525 Shell Programming and Scripting 1 04-20-2009 02:52 PM
Command to replace character HLee1981 UNIX for Dummies Questions & Answers 5 10-17-2005 02:27 AM



All times are GMT -4. The time now is 12:57 AM.