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
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.