1827262 Members
2344 Online
109717 Solutions
New Discussion

problem with vi command

 
felice_2
Occasional Advisor

problem with vi command

Hello to All,
I need to do a mv file pippo.txt
in a file pipponew.txt , but the file pipponew.txt
must not have more than 120 characters for line.
Someone knows how can I do?
Thank you very much

Felix
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: problem with vi command

You want to truncate lines?
You can use fold(1) to break it at 120:
fold -120 pippo.txt > pipponew.txt

If you want to truncate, you can use awk(1) with a printf to limit the line length.
James R. Ferguson
Acclaimed Contributor

Re: problem with vi command

Hi Felix:

As Dennis, noted, 'swk' is an easy way to truncate your lines if that is your choice. It's as simple as:

# awk '{print substr($0,1,10)}' pipponew.txt

...which prints 10-characters beginning from the first (1) character of every line ($0).

Regards!

...JRF...
felice_2
Occasional Advisor

Re: problem with vi command

Dennys,James
Thank you very much,
with your suggestion , I solved the problem.
Thank you once again

Felix
Dennis Handly
Acclaimed Contributor

Re: problem with vi command

>I solved the problem.

If you are happy with your answers, you should reopen the thread and assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#41
http://forums.itrc.hp.com/service/forums/helptips.do?#33