Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
unable to remove \240 from a text file

I have a file originally provided from a SQL database on a Windows platform.

I transfer the file via ftp in binary format, remove the ^M's from the end of all lines.

I have attempted to use tr ( cat infile | tr -d '\240' ) and sed (cat infile | sed 's/\240//g' ) to remove the occurences of \240 in the file with no luck.

I have no problem removing this octal character in vi.

If i run the Windows command, 'type infile', \240 shows up as an a with a grave over it.

In notepad, it shows up as a space.

I need to incorporate into a script a method of deleting these octal characters because other unix commands fail w/ the following error:

can't read STDIN: Illegal byte sequence

Any ideas would be greatly appreciated.

Thx in advance,

pat

Last edited by pbrowne; 12-19-2008 at 11:14 AM..
Sponsored Links
    #2  
Old 12-19-2008
System Shock's Avatar
Registered User
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 558
Thanks: 0
Thanked 7 Times in 6 Posts

Code:
 sed 's/\\240//g' file

Sponsored Links
    #3  
Old 12-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
tried this - it did not find and replace the \240

there was no change after running this command

pat
    #4  
Old 12-19-2008
Registered User
 

Join Date: Sep 2008
Posts: 246
Thanks: 0
Thanked 8 Times in 8 Posts
Hi,

try


Code:
sed 's/\o240//g' file

HTH Chris
Sponsored Links
    #5  
Old 12-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
tried

sed 's/\o240//g' file

no luck - didn't know if this was o240 or 0240 so i tried both to no avail

thx

pat
Sponsored Links
    #6  
Old 12-19-2008
System Shock's Avatar
Registered User
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 558
Thanks: 0
Thanked 7 Times in 6 Posts
Quote:
Originally Posted by pbrowne View Post
tried this - it did not find and replace the \240

there was no change after running this command

pat
What do you mean "there was no change"? No change in the output or no change in the file? The sed command doesn't edit the file,m just display changes to standard output. You need to redirect the output to another file, or of you have gsed, I believe there is a -e flag that will actually edit the file.


Code:
# cat file
 hello \240 world \240hello\240world

# sed 's/\\240//g' file
 hello  world helloworld
#

Sponsored Links
    #7  
Old 12-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
system shock,

i ran your command and redirected the output to another file:

sed 's/\\240//g' file > output_file

the output_file still has the \240 characters in it.

sorry to be vague.

pat
Sponsored Links
Closed Thread

Tags
shell script, shell scripting, unix commands, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed to remove 1st two characters every line of text file ajp7701 Shell Programming and Scripting 20 06-09-2009 04:06 PM
Best way to remove sections of text from a file cals64 Shell Programming and Scripting 8 09-22-2008 12:16 PM
remove specified text from file raidzero Shell Programming and Scripting 2 06-19-2008 09:10 AM
remove the text (*@yahoo.com, hotmail.com) from one file juniorbear Shell Programming and Scripting 11 06-15-2008 07:37 AM
how to remove ^M from windows text file in unix pragy1999 Shell Programming and Scripting 1 04-13-2006 10:04 AM



All times are GMT -4. The time now is 05:18 AM.