Replacing a delimiter

Kaladhar Teja

I have a file with ^A as a delimiter:

8bf9f1897035297fb7b0767e4e5e191b2c93ceb^AAustralia^A2016-01-13 05:19:06^A
8bf9f1897035297fb7b0767e4e5e191b2c93ceb^AAustralia^A2016-01-13 05:19:06^A
8bf9f1897035297fb7b0767e4e5e191b2c93ceb^AAustralia^A2016-01-13 05:19:06^A

How can I replace the delimiters with | using awk or sed?

Desired output:

8bf9f1897035297fb7b0767e4e5e191b2c93ceb|Australia|2016-01-13 05:19:06|
8bf9f1897035297fb7b0767e4e5e191b2c93ceb|Australia|2016-01-13 05:19:06|
8bf9f1897035297fb7b0767e4e5e191b2c93ceb|Australia|2016-01-13 05:19:06|
peak
  1. If you are referring to the control-A character:

    • The following will work with both GNU and non-GNU sed: sed 's/\x01/|/g'
    • Possibly faster would be tr '\001' '|'
  2. If you are referring to the two-character sequence ^A:

    • sed 's/\^A/|/g'
    • in awk you could use gsub( /\^A/,"|" )

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related