The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

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

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-19-2008
pbrowne pbrowne is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
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 12:14 PM..
  #2 (permalink)  
Old 12-19-2008
System Shock's Avatar
System Shock System Shock is offline Forum Advisor  
Registered User
  
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 521
Code:
 sed 's/\\240//g' file
  #3 (permalink)  
Old 12-19-2008
pbrowne pbrowne is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
tried this - it did not find and replace the \240

there was no change after running this command

pat
  #4 (permalink)  
Old 12-19-2008
Christoph Spohr Christoph Spohr is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 205
Hi,

try

Code:
sed 's/\o240//g' file
HTH Chris
  #5 (permalink)  
Old 12-19-2008
System Shock's Avatar
System Shock System Shock is offline Forum Advisor  
Registered User
  
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 521
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
#
  #6 (permalink)  
Old 12-19-2008
pbrowne pbrowne is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
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
  #7 (permalink)  
Old 12-19-2008
pbrowne pbrowne is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
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
Reply

Bookmarks

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0