The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep for a particular pattern and remove few lines above top and bottom of the patter fed.linuxgossip Shell Programming and Scripting 17 07-25-2008 05:29 AM
Remove/Find files based on position pattern kumarn Shell Programming and Scripting 1 06-24-2008 11:53 AM
sed remove everything up to the pattern katrvu Shell Programming and Scripting 4 04-08-2008 06:35 PM
How to remove sudo program unitipon SUN Solaris 1 11-16-2007 12:29 AM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 12:41 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-25-2008
Registered User
 

Join Date: Jan 2007
Posts: 14
Program to remove a pattern

Hi,

I want to remove all occurances of a character which follows a ^ symbol.

For ex:

This is a Test ^H^@^@^@^@^@^@ File used in VI. ^@^@^B^VDM-BM-$|M-^_M-F^AM-

In the above example, I should remove all characters which follows a ^.
(^H ^@ ^B ^V etc) and It should print This is a Test File used in VI

Is there a program or a cmd which I can use to do this?

Thanks & Regards
Sheshadri
Reply With Quote
Forum Sponsor
  #2  
Old 06-26-2008
Registered User
 

Join Date: Jan 2007
Posts: 14
Quote:
Originally Posted by arsheshadri View Post
Hi,

I want to remove all occurances of a character which follows a ^ symbol.

For ex:

This is a Test ^H^@^@^@^@^@^@ File used in VI. ^@^@^B^VDM-BM-$|M-^_M-F^AM-

In the above example, I should remove all characters which follows a ^.
(^H ^@ ^B ^V etc) and It should print This is a Test File used in VI

Is there a program or a cmd which I can use to do this?

Thanks & Regards
Sheshadri
Instead of above..solution for the following will help me.

I have to eliminate all characters between ^ and a space in a file.

Following lines -
Test ^ H^@^@^@^@^@^@^B^VDM-BM-$|M-^_M-F^AM- File1
Test^H^@^@^@^@^@^F^A^X^@^SM-s^TM-3M-G^A File2
Should be printed as below
Test File1
Test File2

I used sed '/^/,/ /d' command, but it is not working.

Please help me out.

Thanks & Regards
Sheshadri
Reply With Quote
  #3  
Old 06-26-2008
Registered User
 

Join Date: Oct 2007
Posts: 74
Hi,

Try this,

Code:
sed 's/\^.[^ ]*//g' input.txt
Regards,
Chella
Reply With Quote
  #4  
Old 06-26-2008
Registered User
 

Join Date: Mar 2008
Posts: 107
This looks like a binary format file when viewed with vi. Control codes are displayed as ^X . See "man ascii" for a table of these codes. For example "^@" is a null character (Hex 00).

Try visually comparing the output of:
strings filename | pg
cat -v filename | pg

If the ^X characters disappear in the "strings" version, the file contains control codes rather than actual "^" characters.

Accurate processing of a binary format file with text file programs such as "vi" , "sed" and "awk" is unlikely to produce a useful conversion. Your will need a proper program. If you just want to see an overview of the contents then "strings" will suffice.
Reply With Quote
  #5  
Old 06-26-2008
Registered User
 

Join Date: Jan 2007
Posts: 14
Thanks Chella,

sed 's/\^.[^ ]*//g' input.txt is working.

Is there a way to remove all characters from start of line till some character say ^.

Thanks & Regards
Shesha
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 01:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0