Reputation: 13
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|
Upvotes: 0
Views: 104
Reputation: 116720
If you are referring to the control-A character:
sed 's/\x01/|/g'
tr '\001' '|'
If you are referring to the two-character sequence ^A
:
sed 's/\^A/|/g'
gsub( /\^A/,"|" )
Upvotes: 2
Reputation: 41548
If your version of sed
is GNU sed, you can use GNU Extensions for Escapes in Regular Expressions, in particular:
`\cX' Produces or matches `CONTROL-X', where X is any character. The precise effect of `\cX' is as follows: if X is a lower case letter, it is converted to upper case. Then bit 6 of the character (hex 40) is inverted. Thus `\cz' becomes hex 1A, but `\c{' becomes hex 3B, while `\c;' becomes hex 7B.
So that would be:
sed -e "s/\ca/|/" < input.txt
Upvotes: 1