Solved

How to remove \240 character from the flat file using sed.

Posted on 2008-10-10
3
2,860 Views
Last Modified: 2013-12-26
How to clean up the \240 character from the file line by line ?
0
Comment
Question by:vishali_vishu
3 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 22690733
requirement not clear, can you elaborate?
0
 
LVL 48

Accepted Solution

by:
Tintin earned 250 total points
ID: 22690833
Do you mean octal 240 character?

In which case you can do

sed "s/\0240//" file >file.new
0
 
LVL 7

Expert Comment

by:Murugesan Nagarajan
ID: 22921856
The following command:
      sed -i.bak 's/240/Murugesandins/'  fileName
creates the backup file with the file name as "fileName.bak"
Also the file "fileName" is getting updated.
########################################################################################
Regarding removals:
-------------------
Use the following command to remove the first occurence of "240" in each line
      sed -i.bak 's/240//'  fileName
Use the following command to remove all the occurences of "240" in each line
      sed -i.bak 's/240//g'  fileName

Use the following command to remove the first occurance of "\0240"
      sed -i.bak "s/\\\0240//" fileName
Use the following command to remove the first occurance of "\0240"
      sed -i.bak "s/\\\0240//g" fileName

Use the following command to replace the first occurance of "\0240" with "\"
      sed -i.bak 's/\0240//' fileName
Use the following command to replace all the occurances of "\0240" with "\"
      sed -i.bak 's/\0240//g' fileName
########################################################################################
Regarding replacements:
-----------------------
Use the following command to replace the first occurence of "240" in each line with murugesandins
      sed -i.bak 's/240/murugesandins/'  fileName
Use the following command to replace all the occurences of "240" in each line with murugesandins
      sed -i.bak 's/240/murugesandins/g'  fileName

Use the following command to replace the first occurance of "\0240" with murugesandins
      sed -i.bak "s/\\\0240/murugesandins/" fileName
Use the following command to replace the first occurance of "\0240" with murugesandins
      sed -i.bak "s/\\\0240/murugesandins/g" fileName

Use the following command to replace the first occurance of "\0240" with "\"
      sed -i.bak 's/\0240/murugesandins/' fileName
Use the following command to replace all the occurances of "\0240" with "\"
      sed -i.bak 's/\0240/murugesandins/g' fileName
########################################################################################                                    
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get a Perl script to return content from a module 7 80
EXCHANGE, ACTIVE DIRECTORY 4 65
Sed question 2 86
Call Shell Script from Perl Script 6 102
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question