Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
up vote 5 down vote accepted
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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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