Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

hi I have the following awk commnad I want to cut the file from start to end please advice why awk not work

   awk -v PARAM=start -v PARAM1=end '/PARAM/,/PARAM1/' file

file:

2324
443
start
43
end
545

required file

start
43
end
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can't use variables between slashes. Use the match operator ~ or the equality operator ==:

awk -v PARAM=start -v PARAM1=end '$0 ~ PARAM,$0 ~ PARAM1' file

or

awk -v PARAM=start -v PARAM1=end '$0 == PARAM,$0 == PARAM1' file
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.