Thread: Sed and the nth-occurence flag.

  1. #1
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

    Sed and the nth-occurence flag.

    Basically I need to enter a character in a string of lines every n spaces such as
    abc#efg#ijk#lmn#
    and with sed I can only enter it in the first place using the flag such as
    Code:
    sed 's/./#/4'
    Is there a way that sed can do it as I would like in the first example rather than just finding the first 4th character and nothing after that. Is there a way to apply the global flag along side with it?

  2. #2
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Found it out

    Code:
    sed 's/.\{4\}/&#/g'

Popular pages Recent additions subscribe to a feed
Website Security Test