Re: Thanks

From: Birger Blixt (Birger.Blixt_at_uab.ericsson.se)
Date: 03/31/04


Date: Wed, 31 Mar 2004 13:01:03 +0200

On 2004-03-30 20:02, Han JIANG wrote:

>
> "Chris F.A. Johnson" <c.fa.johnson@rogers.com> wrote in message
> news:c4ccl4$2g0aq2$1@ID-210011.news.uni-berlin.de...
>
>>On Tue, 30 Mar 2004 at 17:16 GMT, Han JIANG wrote:
>>
>>>Hi,
>>>I am a newbie on unix. I met a strange problem here on Origin 2000.
>>>
>>>I created a text data file which had 1,000 lines on my pc (Windows of
>>>course) and upload it to my acoount on Origin.When I use vi to edit it
>
> on
>
>>>Origin, I found there is a additional blank line between every 2 lines!
>>>That makes my program cann't input this datafile.
>>>
>>>Who know what happen here? And how can erase these additional blank
>
> lines?
>
>>>Please don't say erase them line by line since I have 1000 lines there.
>>
>>grep -v '^$' FILE >NEWFILE
>>
>> Or:
>>
>>grep '.' FILE >NEWFILE
>>
>> Or:
>>
>>awk '/./' FILE >NEWFILE
>>
>> etc......
>>
>>--
>> Chris F.A. Johnson http://cfaj.freeshell.org/shell
>> ===================================================================
>> My code (if any) in this post is copyright 2004, Chris F.A. Johnson
>> and may be copied under the terms of the GNU General Public License
>
>
> It works!
> Thanks a lot!
>
> Han JIANG

You can do that inside vi , using !G or in ex-mode :%!
vi and ex is the same program,
  ls -li /bin/{ex,vi}
     363730 -r-xr-xr-x 5 root bin 226464 Mar 2 2002 /bin/ex*
     363730 -r-xr-xr-x 5 root bin 226464 Mar 2 2002 /bin/vi*

example !Ggrep -v '^$'
When you type the ! , nothing happens , then when you type G , you get a ! at the bottom, then type
a unix command that process your text.
Make sure you are at the top first, or do 1G!G
You can use any other range, !100G to line 100 ,
!'a to mark a , set with ma , or !! only the current line :.! in ex ,,, and so on.
(!!date or :.!date replace the current line with the date)
You can also do things like :%!tr '[:upper:]' '[:lower:]' , :%!fmt and millions of other things.

I have to write this, since I see people save a file, do command <file>newfile , mv newfile file ,
vi file , when they can do :%!command
And u to undo if the result was unsuccessful , or if the text go somewhere else, as in !Glpr or
!Gmail user.

So, if you miss some features in vi, remember that it can use UNIX as plugin :-).
(I moved your top posting, so other can understand who I answer.)

/bb