-2

I have a variable with a value double quote in it, i need to do a search on a file and eliminate the line that has the values matching in the variable.

I need to take the line that has name="logisticsUnitHeight" from below

Input:

Row starts
<attrQual name="logisticsUnitHeight" 
row1
row2     
/attrQual>

Output

Row Starts

row1

row2

/attrQual>

The row that has the matching pattern is to be deleted.

closed as unclear what you're asking by Jeff Schaller, Timothy Martin, don_crissti, steeldriver, sam Mar 21 '17 at 23:27

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Where's the code, sample input, and expected output? – thrig Mar 21 '17 at 18:18
  • I need to take the line that has name="logisticsUnitHeight" from below <attrQual name="logisticsUnitHeight" qual="CMT">95.7</attrQual> <attrQual name="logisticsUnitDepth" qual="CMT">120</attrQual> – Parthi Mar 21 '17 at 18:38
  • @Parthi Please update the text of the question with all relevant information rather than leaving it in a comment. – Kusalananda Mar 21 '17 at 20:53
1
needle='something"withaquote'
sed "/$needle/d" /path/to/haystack

or

needle='something"withaquote'
grep -v "$needle" /path/to/haystack

or

awk -v needle='/something"withaquote/' '$0 !~ needle {print}' /path/to/haystack
  • needle='something "with double quote"to be removed' – Parthi Mar 21 '17 at 18:44
  • Still works as described. – DopeGhoti Mar 21 '17 at 18:47
  • sed -i "/$ATTR7/,/$ATTR8/d" $VAL This is the command i use , in that ATTR7 = <attrQualMany name="languageSpecificBrandName"> and ATTR8 = /attrQualMany> – Parthi Mar 21 '17 at 19:00
  • @Parthi Your command is different than your main question.You might think that your problem is the double quote , but looking at what you tried your problems seems to related not to double quotes but to incorrect use of sed. Edit your question, include correct input data, include expected output, include what you tried and what error message you get with your try. – George Vasiliou Mar 21 '17 at 23:41
  • yes, i have done that now, pls let me know further changes – Parthi Mar 22 '17 at 19:10

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