Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    5

    Unanswered: Deleting blank in file

    Hi!

    I want to format this file using unix commande sed or else
    >
    > 1505
    > 1506
    So that it looks like
    >1505
    >1506

    Thanks for your help

  2. #2
    Join Date
    May 2004
    Posts
    5
    it's not clear in the post but my file contain a first blank line that i manage to delete thanks to sed "1d"
    But after that the number are precieded by a blank too this way
    blankblankblank1505
    blankblankblank1506

    How can i delete the blank in the second,the third and so one in the file to format the file like
    1505
    1506
    1507
    ...

  3. #3
    Join Date
    May 2004
    Location
    Barcelona, Spain
    Posts
    54
    Quote Originally Posted by Moustifay
    it's not clear in the post but my file contain a first blank line that i manage to delete thanks to sed "1d"
    But after that the number are precieded by a blank too this way
    blankblankblank1505
    blankblankblank1506

    How can i delete the blank in the second,the third and so one in the file to format the file like
    1505
    1506
    1507
    ...
    See man sed for an explanation on option s/regexp/replacement
    You can look up man grep for help on regular expressions too.

    Cheers

  4. #4
    Join Date
    Feb 2004
    Posts
    143
    You can remove all blank lines from a file (say sample_file.txt) by doing :

    sed '/^$/d' sample_file.txt

    Hope this is what you needed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •