Solved

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

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

688 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