Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

MGW:^FVMG107
MGW:^FVMG113
MGW:^FVMG108
MGW:^FVMG103

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

3 Answers

^F is the way vim is tellying 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 7 hours ago
add comment

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
3  
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 10 hours ago
    
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 8 hours ago
    
@godlygeek and Scott thanks for the info :)! –  polym 7 hours ago
add comment

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

Your Answer

 
discard

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.