Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting the first 6 characters on a line within vi 2

Status
Not open for further replies.

jrothey

Technical User
Jul 1, 2005
19
0
0
US
I have some output from a script that I'm trying to modify for another program, the data exist in a vi file, but the header information needs to be dropped. I know how to delete characters to the end of a line with D, but I'm trying to delete the first 6 characters from several lines of information.

Is there a global vi command that'll delete the first X number of characters off of lines?
 
Delete the first 6 characters from all lines:
:1,$s!^......!!

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

after deleting the first 6 characters of every line in a text file, how can I insert sequential line #'s there?

I want to do something like:

%s/^/.=/

where .= in vi normally returns the current line number in command mode.

Any suggestions?

TIA

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
I'd use the -n option of the pr command.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That works. I am using the following:

pr -n@5 -t myfile > my-new-file

then I have to edit my-new-file to replace the first @ on every line with a zero. If I don't use the -nck option, pr inserts a tab between the line numbers and the rest of the line, which I don't want.

Close enough to what I need.

Thanks, PHV!


Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top