Solved

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

Posted on 2008-10-10
3
2,818 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
reinstall 1 57
Parsing a file using ksh 10 48
aix tls version 6 161
AIX 5.x set up arrow to recall 11 42
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Utilizing an array to gracefully append to a list of EmailAddresses
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now