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

While editing a unix file I'm getting data as below in vi editor.


where in above data ^F is not viewable in cat command. I have tried dos2unix & sed also, but it still exists. How can I remove ^F

share|improve this question

^F is vim telling you there is a non-printable character 0x06 there (F is the sixth letter of the alphabet, they range: '^@', '^A', '^B'... '^Y', '^Z'. '^[', '^\', '^]', '^^', '^_')

I had no problem removing it graphically in vim, nano, joe… but if you prefer a command line approach, knowing that it's the character 0x06, you can use sed -i 's/\x06//g' filename to remove it.

PS: I'm afraid polym solution of removing ^F on cat -v will only work if your file doesn't have any other unprintable characters, which would get mangled.

share|improve this answer
Thanks, I modified my solution :). Nice eye! – polym Jun 30 '14 at 16:51

As Ángel says, ^F in vi or the output of cat -v denotes an 06 character.  Another way of getting rid of these characters is

tr -d "\06" < oldfile > newfile
share|improve this answer

Edit: As Angel mentioned, you shouldn't use this solution, since it might produce undesirable changes.

His solution (hex(^F)==\x06):

sed -i 's/\x06//g' filename

My (inproper) solution:

cat -v oldfile | sed 's/\^F//g' > newfile

should do it.

share|improve this answer
As Ángel says below, this will potentially make other undesirable changes to the contents of the file - it's not a very general answer to the question. – godlygeek Jun 30 '14 at 13:42
In addition to Ángel’s comment (referring to the functionality of cat -v), this will also cause corruption if the file happens to have any ^ characters that are immediately followed by F characters. – Scott Jun 30 '14 at 15:57
@godlygeek and Scott thanks for the info :)! – polym Jun 30 '14 at 16:52

Given that you're working with the file in vim, you can fix this within vi/vim too. You can type these character with ctrl-v, then ctrl-. For this, it's crtl-v, followed by ctrl-f.

So, you can use a simple find/replace:


That would work on all lines (the %), and replace (the s), the first instance of ^F, with nothing, effectively removing it.

If you want to see hidden characters in files, instead of cat, try using od -c:

od -c <file name>

eg, but putting a ^F and two line-endings in a file:

alex@Smiley:/tmp|⇒  cat test

alex@Smiley:/tmp|⇒  od -c test
0000000  006  \n  \n

This prints out all characters escaped, including tabs, line endings, etc.

If you want to use sed, you can use the same ctrl-V, crtl- trick right on the command-line too. That way you don't need to remember the translation.

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.