sed to get rid of unwanted characters

so i have strings such as this:

'postfix/local#2,5#|CRON.*12062.*root.*CMD#2,5#|roice.*NQN1#1,2#|toysprc#1,4#'

i need to get rid of the "#" and the numbers between them for each of the strings above. so the desired output should be:

'postfix/local|CRON.*12062.*root.*CMD|roice.*NQN1|toysprc'

i tried the following:

echo 'postfix/local#2,5#|CRON.*12062.*root.*CMD#2,5#|roice.*NQN1#1,2#|toysprc#1,4#' | sed 's_#.*&#__g'

echo ''postfix/local#2,5#|CRON.*12062.*root.*CMD#2,5#|roice.*NQN1#1,2#|toysprc#1,4#' | sed 's_#&#__g'

Try:

echo 'postfix/local#2,5#|CRON.*12062.*root.*CMD#2,5#|roice.*NQN1#1,2#|toysprc#1,4#' | sed 's_#[^#]*#__g'
1 Like