Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have lines in a file that look like this:

FA General,1234567^^^^^FA Student Letter- General^<<undefined>>^\pathofile.RTF

I'm trying to use sed to replace the caret characters with commas. If I use:

sed 's/^/,/' file.txt

Nothing changes. I've also tried

sed 's/\^/,/' file.txt
sed 's/^^/,/' file.txt

What am I missing here?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

Do you want to replace all carets? I am sure if you look closely at your result you'll see that the first caret is replaced. So try this:

sed -e 's/^/,/g' file.txt

Note the g to mean global replace, i.e, all matches.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...