1

I have a text file like this:

info  Some info here

In which when I use cat -A display this:

info^I Some info here

How do I edit this so I'll get something like this instead:

info<space>-<space>Some info here

1 Answer 1

5
sed 's/\t/ -/' inputfile

if that pattern appears multiple times on a line, use the global option:

sed 's/\t/ -/g' inputfile

if you want to restrict it to certain lines, for example that start with "info":

sed '/^info/ s/\t/ -/' inputfile

You can use the -i option to edit the file in place:

sed -i 's/\t/ -/' inputfile

If you don't do that you can do this equivalent operation

sed 's/\t/ -/' inputfile > outputfile && mv outputfile inputfile

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.