0

I have a variable "header", and if there is the chaine "last" inside it i'd like to do nothing, but if the chain "last" is not inside my variable, i'd like to delete the whole variable (header = "")

I was searching for sth like this, but obviously it doesn't work like this.

echo $header | sed "/!'last'//"

How to do a negation with sed? Can someone help me please?

Thank you

0

2 Answers 2

0

or in awk

header=$(echo $header | awk '!/last/')
Sign up to request clarification or add additional context in comments.

Comments

0
header=`echo $header |  sed '/last/d'`

or

header=`echo $header |  sed -e 's/.*last.*//g'`

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.