How to use Sed to remove characters from file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grinder332518
    New Member
    • Jun 2009
    • 28

    How to use Sed to remove characters from file?

    My pipe delimited file is coming over with spurious “\” characters inserted into some alpha fields,
    which is causing the records to be split into 2.

    Eg Abc|def|10/11\
    AAAA|xyz
    Lmn|opq|10/11BBBB|xyz
    etc etc
    I am having to go into vi, then enter /\ to locate each occurrence, enter x to delete the character,
    then enter shift and J to join the two into one.

    I have been advised that I can use a “sed” type file to automate this,but do not know how,
    nor the syntax to be used

    Can anybody please help ?
  • Mariostg
    Contributor
    • Sep 2010
    • 332

    #2
    I don't have vi in fromt of me ta the moment, but how about this in vi :%s#\\\n##g

    Comment

    • grinder332518
      New Member
      • Jun 2009
      • 28

      #3
      thanks Mariostg
      I actually came up with

      sed -e :a -e '/\\$N; s/\\\n//; ta'

      which is more or less what you are proposing.

      Best Regards

      Comment

      Working...