![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
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 |
|
#3
|
|||
|
|||
|
Hi,
Try this, Code:
sed 's/\^.[^ ]*//g' input.txt Chella |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |