VI Question

I have a document with carrots at the beginning of every line. The document is extremely long. How would I go about deleting the first character of every line in one quick command. I've looked through tons of VI documents and can't find an answer.

Thanks!

once your in vi.

:%s/^ctrl+v//g

the ctrl+v will produce a ^.

and i belave my syntax should be correct and look at the beginning of the line then look for a Carrot as the next charter. but if you want to get ride of all carrots in the file just use

:%s/ctrl+v//g

i am sure you can also use the tr (translate) utility if you wanted.

man tr

Hello, how are you doing? In order to delete the first carrot of every line, do the following:

cut -c -d2- oldfilename> new file name

e.g. cut -c -d2- JHeliosfear > JHeliosfear2

What you should now be left with is the second character of every line onward. I hope this resolves your issue...:slight_smile:

Unfortunatley I'm with that command I'm getting:

$ cut -c -d2- config1 > config2
cut: invalid character in range

Hi,

Try cut -c 2- oldfile > newfile

LY18

My humblest apologies.. I did not mean to include the "d"elimeter option within my solution to you. The person who wrote immediately after your response was correct. The command goes as follows:

cut -c2- old > new

You can use
:%s/ctrl+v//g
but with the g option it will remove all the occurences of the carrat from your document. If you want to remove the carrat only from the begining i.e only the first occurence then simply omit the g from the end of the command
:%s/ctrl+v//

This Works!

I hate to ask another question, but I have looked at the "cut" man page and cannot find the answer.

Why are you using -c2-; i.e., why doesn't -c1- work for the first character?

Thanks!

the '-c 2-' is actually a range specification, on Redhat, I looked at:
"info cut"
this gave me more detail than the man page and it explained that the -c option is used with a range, ie '1-' is the same as '1-[end of line]' and so allows for dynamic line lengths. the same way that '-8' is equivelent to '1-8' so the range '2-' is actually from the second character in the line to the end of the line.

hope this helps....

That explains it.

Thanks everyone!

Radimus