leave each Nth line, if contains .... (in script)

  • Hi

    I have a file like this:

    BBBBB - 11111
    BBBBB - 22222
    BBBBB - 33333
    BBBBB - 44444
    BBBBB - 55555
    BBBBB - 66666
    BBBBB - 77777
    BBBBB - 88888
    BBBBB - 99999
    BBBBB - 00000

    first request - i would like to work only on the lines that contain BBBBB and leave every 5th line of them
    second request - i would like to delete all lines that contain a specific string

    I need these to run in a script

    many thanks

  • Hello, @gonen-shoham,

    I understood that you’re interested on lines containing the string BBBBB only, and, also, that you would like to delete lines with a specific string. But, as English is not my native language, I’m still wondering about the expression leave every 5th line of them !

    May be, you could show us from your initial text, or other text, what is the exact text that you expect to ?

    Best Regards,


  • @Gonen-Shoham

    in addition to what Guy already mentioned, it would be good to know what kind of
    scripting language you are thinking of.


Log in to reply