[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2008-10-10
3
Medium Priority
?
2,974 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Expert Comment

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

Accepted Solution

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

In which case you can do

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

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

649 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