Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed to remove carriage return 1

Status
Not open for further replies.

fortune

Technical User
Oct 31, 2001
14
US
hi,
i am using utl_file to insert data into tables . the data file is read terminated by |,| .but the procedure exits as the data file has line feeds in between. is there a way of removing these line feeds.

for example |,|. MDA
. Candidate must be able to cover the geographic areas of Orlando, Gainesville, Daytona and Jacksonville, FL and overnight travel approximately 20 –25%.

Thanks in advance
 
Not sure if this is the answer you need, but have you tried feeding the data file through dos2unix before processing it, eg:

dos2unix <oldfile> <newfile>

Hope this helps. If not, post back.
 

to remove any character by hex number (in this case CR):
cat filename|sed 's/'`echo &quot;\013&quot;`'//g' > filenew

and if you've got LF/CR (0A0D) and you just want CR
cat filename|sed 's/'`echo &quot;\010\013&quot;`'/'`echo &quot;\013&quot;`'/g' > filenew

HTH ;-)

Dickie Bird
db@dickiebird.freeserve.co.uk
 
the translate (tr) command has a -d option for removing a character from an input stream, its a little lighter than sed.
cat ${filename} | tr -d '\r' > ${filename}.new


 
Why can't I get

cat filename|sed 's/'`echo &quot;\013&quot;`'//g' > filenew

to work? I keep getting the message

&quot;First RE may not be null&quot;

Note: isn't \013 decimal, not hex? Which is correct? (I get the same message or no change to the output whatever I use)

Thanks
 
Dickie Bird's solution didn't work on my computer,
which is a sun box.

Anyway, you can always create your own little script
and add the control character in vi using the sequence:
CONTROL V, CONTROL M

When done, the script should look like:

sed -e 's/^M//g' $input_file > $input_file.fmt

Or, a more robust sed option is to remove all non-printable
characters in one fell swoop:

sed -e 's/[^ -~]//g' $input_file > $input_file.fmt

dos2unix works good, too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top