Sed and the nth-occurence flag.

This is a discussion on Sed and the nth-occurence flag. within the Linux Programming forums, part of the Platform Specific Boards category; Basically I need to enter a character in a string of lines every n spaces such as abc#efg#ijk#lmn# and with ...

  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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21