Removing blank lines in a file... - VMS

This is a discussion on Removing blank lines in a file... - VMS ; Hi: Can You show me a simple procedure to remove all blank lines in a file ? Thank You in advance......

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 27

Thread: Removing blank lines in a file...

  1. Removing blank lines in a file...

    Hi:
    Can You show me a simple procedure to remove all blank lines in a
    file ?
    Thank You in advance...

  2. Re: Removing blank lines in a file...

    In article <4b1a79c5-c94a-4927-a8c4-f1eedf447ca7@w40g2000hsb.googlegroups.com>, apogeusistemas@gmail.com writes:

    > Can You show me a simple procedure to remove all blank lines in a
    > file ?


    $ EDIT/TECO file.ext

    $
    $;2r>ex$$

    where all but the first "$" are the Escape character.

  3. Re: Removing blank lines in a file...

    apogeusistemas@gmail.com wrote:
    > Hi:
    > Can You show me a simple procedure to remove all blank lines in a
    > file ?
    > Thank You in advance...


    I'll write one if you pay me! It's cheaper to do your own homework and
    you'll learn more!!!!!



  4. Re: Removing blank lines in a file...

    Richard B. Gilbert wrote:
    > I'll write one if you pay me! It's cheaper to do your own homework and
    > you'll learn more!!!!!


    Watch out for that newfangled thing called open source, it can ruin your
    revenu source !


    $OPEN/read input myfile.txt
    $OPEN/write output yourfile.txt
    $!
    $LOOP:
    $ READ/END=ENDLOOP input buffer
    $ test = F$EDIT(buffer,"COLLAPSE") ! removes all spaces/tabs
    $ IF test .eqs. "" then goto LOOP
    $ write output buffer
    $ goto loop:
    $!
    $endloop:
    $close input
    $close output
    $write sys$output "Done"
    $exit

  5. Re: Removing blank lines in a file...

    On 11 dez, 20:08, JF Mezei wrote:
    > Richard B. Gilbert wrote:
    > > I'll write one if you pay me! It's cheaper to do your own homework and
    > > you'll learn more!!!!!

    >
    > Watch out for that newfangled thing called open source, it can ruin your
    > revenu source !
    >
    > $OPEN/read input myfile.txt
    > $OPEN/write output yourfile.txt
    > $!
    > $LOOP:
    > $ READ/END=ENDLOOP input buffer
    > $ test = F$EDIT(buffer,"COLLAPSE") ! removes all spaces/tabs
    > $ IF test .eqs. "" then goto LOOP
    > $ write output buffer
    > $ goto loop:
    > $!
    > $endloop:
    > $close input
    > $close output
    > $write sys$output "Done"
    > $exit


    Thank You so much for your help...

  6. Re: Removing blank lines in a file...


    "Larry Kilgallen" wrote in message
    news:WZKRSFU7PPMq@eisner.encompasserve.org...
    > In article

    <4b1a79c5-c94a-4927-a8c4-f1eedf447ca7@w40g2000hsb.googlegroups.com>,
    apogeusistemas@gmail.com writes:
    >
    > > Can You show me a simple procedure to remove all blank lines in a
    > > file ?

    >
    > $ EDIT/TECO file.ext
    > >
    > $
    > $;2r>ex$$
    >
    > where all but the first "$" are the Escape character.


    How about

    $ EDIT /TECO file.ext
    <@:fn/S
    //;>

    where is control-E, and is Escape. control-E followed by S
    followed by return matches whitespace followed by "new line", and replaces
    text matching that pattern with (nothing). This may need minor adjustment
    depending on exactly what was meant by "blank lines".

    It's been a while so this may not be quite right (it's not been tested by me
    just now), but anyone who wants to see whether it is right or not can Read
    The Fine Manual, the Standard TECO User's Guide, vintage 1985, at
    http://www.ibiblio.org/pub/academic/...o/doc/teco.doc
    and elsewhere. Also available in trendy new PDF format, with updates for
    native TECO32 on VMS V5, vintage 1990, at
    http://h71000.www7.hp.com/doc/73fina...n/pdf/teco.pdf

    Regards
    John



  7. Re: Removing blank lines in a file...

    In article <4b1a79c5-c94a-4927-a8c4-f1eedf447ca7@w40g2000hsb.googlegroups.com>, apogeusistemas@gmail.com writes:
    > Hi:
    > Can You show me a simple procedure to remove all blank lines in a
    > file ?
    > Thank You in advance...


    Yes. Is there some reason why should help you with such a trivial
    task?


  8. Re: Removing blank lines in a file...

    In article
    <4b1a79c5-c94a-4927-a8c4-f1eedf447ca7@w40g2000hsb.googlegroups.com>,
    apogeusistemas@gmail.com wrote:

    > Hi:
    > Can You show me a simple procedure to remove all blank lines in a
    > file ?
    > Thank You in advance...


    There are probably a dozen different ways to do this in Perl. Here's
    one of the more verbose ones:

    $ perl -i -ne "chomp; print qq/$_\n/ if length $_;" foo.txt

    --
    Posted via a free Usenet account from http://www.teranews.com


  9. Re: Removing blank lines in a file...



    $ type fred.txt
    line 1
    Line 2
    Line 3

    Line 4
    Line 5

    Line 6
    Line 7

    Line 8
    Line 9

    Last


    $ search fred.txt "" /out=fredless.txt/log
    %SEARCH-S-MATCHED, FRED.TXT;1 - 15 records, 10 matches
    $ ty fredless.txt
    line 1
    Line 2
    Line 3
    Line 4
    Line 5
    Line 6
    Line 7
    Line 8
    Line 9
    Last
    $

  10. Re: Removing blank lines in a file...

    JF Mezei wrote:
    > Richard B. Gilbert wrote:
    >> I'll write one if you pay me! It's cheaper to do your own homework and
    >> you'll learn more!!!!!

    >
    > Watch out for that newfangled thing called open source, it can ruin your
    > revenu source !
    >
    > $OPEN/read input myfile.txt
    > $OPEN/write output yourfile.txt
    > $!
    > $LOOP:
    > $ READ/END=ENDLOOP input buffer
    > $ test = F$EDIT(buffer,"COLLAPSE") ! removes all spaces/tabs
    > $ IF test .eqs. "" then goto LOOP
    > $ write output buffer
    > $ goto loop:
    > $!
    > $endloop:
    > $close input
    > $close output
    > $write sys$output "Done"
    > $exit


    Is the code GPL or LGPL or Apache licensed ?

    :-)

    Arne

  11. Re: Removing blank lines in a file...

    Yeah.. really can't figure that out?
    Anyway, just to be cute...

    How about a truly minimalistic awk program:

    $ gawk "length" file.dat

    This executes the length function on the default input line $0 and
    take the default action to print $0 if true ( != 0)
    If you also want to get rid of lines with just spaces or tabs, change
    to the even shorter:

    $ gawk "NF" file.dat

    That NF is a symbol representing the number of 'fields' on the default
    input line, if true, take default action: print!
    A more explicit way to write that:

    $ gawk "/[^ \t]/" file.dat /out=stripped.dat

    This uses a regular expresion to look for a string which contains
    characters NOT (^) in the character set space and tab ([ \t])

    In Perl that could be

    $ perl -ne "print if /\S/" file.dat

    in perl regexpr's the \s means 'whitespace', and \S means NOT
    whitespace

    The test for an empty line in perl seems to be handicapped with the
    new-line or not.
    This works for me:

    $ perl -lne "print if length" file.dat > stripped.dat

    grins,
    Hein.

  12. Re: Removing blank lines in a file...

    JF Mezei wrote:
    > Richard B. Gilbert wrote:
    >
    >>I'll write one if you pay me! It's cheaper to do your own homework and
    >>you'll learn more!!!!!

    >
    >
    > Watch out for that newfangled thing called open source, it can ruin your
    > revenu source !
    >
    >
    > $OPEN/read input myfile.txt
    > $OPEN/write output yourfile.txt
    > $!
    > $LOOP:
    > $ READ/END=ENDLOOP input buffer
    > $ test = F$EDIT(buffer,"COLLAPSE") ! removes all spaces/tabs
    > $ IF test .eqs. "" then goto LOOP
    > $ write output buffer
    > $ goto loop:
    > $!
    > $endloop:
    > $close input
    > $close output
    > $write sys$output "Done"
    > $exit


    And what did you get for writing that? You pissed away five or ten
    minutes of your life for no return. You probably also did his homework
    for him and ruined the learning experience he was supposed to get by
    doing it himself!

    I would have done it in gawk! I have a VMS port of an ancient version
    of gawk. If anyone wants it, I could put it on my web page. . . . It's
    a very handy tool when you need what it does. . . .





  13. Re: Removing blank lines in a file...

    Richard B. Gilbert wrote:

    > And what did you get for writing that?


    A feeling that I may have helped someone and given him an image that
    people on C.O.V. are happy to welcome newbies and help them despite VMS'
    days being numbered.

    I am in the process of learning Unix, and I can tell you that I wish
    there the mac newsgroups had people of C.O.V.'s calibre to help guide me.

    The little DCL I gave the chap wasn't fancy, but it at least shows him
    it is possible to write a DCL script that can open a file and process
    records. He can then use help for each command to learn more.

    It can be daunting when you get to an OS and you know what you want to
    do, but have no clue on what commands can be used to do it.

  14. Re: Removing blank lines in a file...

    JF Mezei wrote:
    > Richard B. Gilbert wrote:
    >
    >
    >>And what did you get for writing that?

    >
    >
    > A feeling that I may have helped someone and given him an image that
    > people on C.O.V. are happy to welcome newbies and help them despite VMS'
    > days being numbered.
    >
    > I am in the process of learning Unix, and I can tell you that I wish
    > there the mac newsgroups had people of C.O.V.'s calibre to help guide me.
    >
    > The little DCL I gave the chap wasn't fancy, but it at least shows him
    > it is possible to write a DCL script that can open a file and process
    > records. He can then use help for each command to learn more.
    >
    > It can be daunting when you get to an OS and you know what you want to
    > do, but have no clue on what commands can be used to do it.


    VMS is about the closest O/S to being "intuitively obvious", at least if
    you are fluent in English.

    Unix development and the idea that terse is good were heavily influenced
    by the devices available as terminals in the 1960s. Typing on them
    required a great deal of effort. My experience was with a Model 33
    Teletype. That experience plus knowing that that was what the Unix
    developers had to work with explains just about everything except why
    things are still done that way!

    You can take someone who knows nothing about computers and get him up
    and running on VMS by little more than showing him how to log in and the
    HELP command.

    Of course some things are still a little obscure! Quick everyone! What
    is "1---1"??
























    It's the expression for the last day of the previous month! Both the
    month and the year are defaulted to the current values. . . .




  15. Re: Removing blank lines in a file...

    on 11-12-2007 21:48 apogeusistemas@gmail.com wrote...
    > Hi:
    > Can You show me a simple procedure to remove all blank lines in a
    > file ?
    > Thank You in advance...


    Yeah, don't follow the TECO examples given. They just work on the first
    TECO "page" of a file (everything up to the first FF or until TECO's
    memory is full, whichever comes first). There should be a Yank loop
    around the commands given IMO.

    --
    Wilm Boerhout Zwolle, NL
    remove OLD PAINT from return address to reply

  16. Re: Removing blank lines in a file...

    Hi,

    gawk 3.1.6 was released this summer.

    $ ftp://ftp.gnu.org/gnu/gawk

    binary

    get gawk-3.1.6.tar.gz

    $ rename/log gawk-3^.1^.6^.tar.gz gawk-3_1_6_tar.gz

    $ gzip -dv gawk-3_1_6_tar.gz

    $ tar -xvf gawk-3_1_6_tar.

    $ set def [.gawk-3_1_6]

    $ type readme.

    $ type [.readme_d]readme.vms

    Follow those instructions; I used [.vms]vmsbuild.com.

    Run the tests as explained in [.vms]vmstest.com.

    Install if you wish.

    Many, many, many thanks to Pat Rankin and Arnold Robbins

    Carl Friedberg

    On Dec 11, 2007 9:37 PM, Hein RMS van den Heuvel
    wrote:
    > Yeah.. really can't figure that out?
    > Anyway, just to be cute...
    >
    > How about a truly minimalistic awk program:
    >
    > $ gawk "length" file.dat
    >
    > This executes the length function on the default input line $0 and
    > take the default action to print $0 if true ( != 0)
    > If you also want to get rid of lines with just spaces or tabs, change
    > to the even shorter:
    >
    > $ gawk "NF" file.dat
    >
    > That NF is a symbol representing the number of 'fields' on the default
    > input line, if true, take default action: print!
    > A more explicit way to write that:
    >
    > $ gawk "/[^ \t]/" file.dat /out=stripped.dat
    >
    > This uses a regular expresion to look for a string which contains
    > characters NOT (^) in the character set space and tab ([ \t])
    >
    > In Perl that could be
    >
    > $ perl -ne "print if /\S/" file.dat
    >
    > in perl regexpr's the \s means 'whitespace', and \S means NOT
    > whitespace
    >
    > The test for an empty line in perl seems to be handicapped with the
    > new-line or not.
    > This works for me:
    >
    > $ perl -lne "print if length" file.dat > stripped.dat
    >
    > grins,
    > Hein.
    >


  17. Re: Removing blank lines in a file...

    In article , Kilgallen@SpamCop.net (Larry Kilgallen) writes:
    > In article <4b1a79c5-c94a-4927-a8c4-f1eedf447ca7@w40g2000hsb.googlegroups.com>, apogeusistemas@gmail.com writes:
    >
    >> Can You show me a simple procedure to remove all blank lines in a
    >> file ?

    >
    > $ EDIT/TECO file.ext
    > >
    > $
    > $;2r>ex$$
    >
    > where all but the first "$" are the Escape character.


    In article <4760192f$0$25477$ba620dc5@text.nova.planet.nl>, Wilm Boerhout writes:
    > on 11-12-2007 21:48 apogeusistemas@gmail.com wrote...
    >> Hi:
    >> Can You show me a simple procedure to remove all blank lines in a
    >> file ?
    >> Thank You in advance...

    >
    > Yeah, don't follow the TECO examples given. They just work on the first
    > TECO "page" of a file (everything up to the first FF or until TECO's
    > memory is full, whichever comes first). There should be a Yank loop
    > around the commands given IMO.


    Your opinion is not correct. The difference between FN and FS is
    that FN provides an automatic Yank whenever required.

    A difference between various TECO posts in this topic is whether
    one is to count line containing space characters as "blank". A
    person writing TECO can decide for themselves (unlike languages
    that consider a null character to implicitly terminate a string).

  18. Re: TECOing blank lines out of a file


    "Wilm Boerhout" wrote in message
    news:4760192f$0$25477$ba620dc5@text.nova.planet.nl ...
    > on 11-12-2007 21:48 apogeusistemas@gmail.com wrote...
    > > Hi:
    > > Can You show me a simple procedure to remove all blank lines in a
    > > file ?
    > > Thank You in advance...

    >
    > Yeah, don't follow the TECO examples given. They just work on the first
    > TECO "page" of a file (everything up to the first FF or until TECO's
    > memory is full, whichever comes first). There should be a Yank loop
    > around the commands given IMO.
    >
    > --
    > Wilm Boerhout Zwolle, NL
    > remove OLD PAINT from return address to reply


    I realise it's a long time since most people used TECO in anger, and that
    these days most people probably view TECO as a historical curiousity rather
    than a useful text-processing tool, but you appear to be thinking of FS,
    rather than FN.

    If you follow the link I provided previously (and which is repeated below)
    and RTFM, you will find in table 5-13 of the FM that an "N" search "performs
    the same function as the S command except that the search is continued
    across page boundaries, if necessary,
    until the character string is found or the end of the input file is
    reached." So, IMHO, and in Larry's opinion, and in the opinion of the people
    who wrote the book, no need for Yanks.

    hth
    John

    FM: http://h71000.www7.hp.com/doc/73fina...n/pdf/teco.pdf



  19. Re: TECOing blank lines out of a file

    John Wallace wrote:
    > "Wilm Boerhout" wrote in message
    > news:4760192f$0$25477$ba620dc5@text.nova.planet.nl ...
    >
    >>on 11-12-2007 21:48 apogeusistemas@gmail.com wrote...
    >>
    >>>Hi:
    >>>Can You show me a simple procedure to remove all blank lines in a
    >>>file ?
    >>>Thank You in advance...

    >>
    >>Yeah, don't follow the TECO examples given. They just work on the first
    >>TECO "page" of a file (everything up to the first FF or until TECO's
    >>memory is full, whichever comes first). There should be a Yank loop
    >>around the commands given IMO.
    >>
    >>--
    >>Wilm Boerhout Zwolle, NL
    >>remove OLD PAINT from return address to reply

    >
    >
    > I realise it's a long time since most people used TECO in anger, and that
    > these days most people probably view TECO as a historical curiousity rather
    > than a useful text-processing tool, but you appear to be thinking of FS,
    > rather than FN.
    >
    > If you follow the link I provided previously (and which is repeated below)
    > and RTFM, you will find in table 5-13 of the FM that an "N" search "performs
    > the same function as the S command except that the search is continued
    > across page boundaries, if necessary,
    > until the character string is found or the end of the input file is
    > reached." So, IMHO, and in Larry's opinion, and in the opinion of the people
    > who wrote the book, no need for Yanks.
    >
    > hth
    > John
    >
    > FM: http://h71000.www7.hp.com/doc/73fina...n/pdf/teco.pdf
    >
    >


    I've only used TECO two or three times in my life but there are a few
    things that TECO can do quickly and easily; things that others cannot do
    or do only with great effort on your part. It is not an editor for the
    faint hearted and you're out of your mind if you don't backup your file
    before you start! An ill chosen keystroke can turn your file into garbage!



  20. Re: TECOing blank lines out of a file

    In article <47607CB8.7090705@comcast.net>, "Richard B. Gilbert" writes:

    > I've only used TECO two or three times in my life but there are a few
    > things that TECO can do quickly and easily; things that others cannot do
    > or do only with great effort on your part. It is not an editor for the
    > faint hearted and you're out of your mind if you don't backup your file
    > before you start! An ill chosen keystroke can turn your file into garbage!


    But on VMS file system versioning takes care of backup automatically
    unless you go out of your way to defeat it.

+ Reply to Thread
Page 1 of 2 1 2 LastLast