Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Sed translation of octal characters

    I'm trying to clean up a DB load file. The file contains a delimiter sequence of '|~' and I need to change it to \265 (the micro symbol).


    sed -e "s/$XBFTFieldDelim/$fieldDelim/g" data.load

    The error I'm getting is:
    sed: -e expression #1, char 11: Invalid reference \2 on `s' command's RHS

    I've tried a lot variations on the command with no success.

    No one at work will give me any help.


  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    This is in a bash script, right?
    fieldDelim=$(echo -e "\xb5")
    sed -e "s/$XBFTFieldDelim/$fieldDelim/g" data.load
    Hope this helps.

    Old age and treachery will overcome youth and skill.

  3. #3
    if you have fields and field delimiters, its easier to work with them using awk
    awk 'BEGIN{FS="[|][~]"}{$1=$1}1' OFS="\265" file

  4. $spacer_open
  5. #4

    Thumbs up

    Thanks Bill, that worked. I tried something similar to that a few weeks ago, but obviously I did not do it right.

    ghostdog74, I did not try the awk code since there are 3 different delimiters that require changing. The sed route seemed to be the most direct at my stage of understanding. I'll put down awk for more studying next month once project work eases up.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts