kumar4world Posted April 25, 2020 Report Posted April 25, 2020 2 hours ago, Kumaravaarma said: @kumar4worldBhayya what does -E and caret do ? Naa output ila kavali ante malli malli adhe cheputaru. Text_two line ravaddu. Let me xplain more in details. Consider there are three statements and all the 3 are in one file. I want the output which starts with text_* and matching keyword with no coming. Both condition satisfy avvali. statement#2 key word not coming ledu kadaa anduke statement#2 skip cheyali Statement#1 text_one: please_come answer: coming and notcoming question_to_answer: y Statement#2 text_two: plese_donot_come answer: nocoming question_to_answer: y Statement#3 text_three: please_come_aftersome answer: coming and nocoming and notcoming question_to_answer: y I want the below output text_one: please_come answer: coming and notcoming text_three: please_come_aftersome answer: coming and nocoming and notcoming Flash Player for Mac Stream and View Video, Audio, Multimedia and Rich Internet Applications. www.electroappsmacs.com @Kumaravaarma grep -E and egrep are same this will work $ cat file.txt text_one: please_come answer: coming and notcoming question_to_answer: y text_two: plese_donot_come answer: nocoming question_to_answer: y text_three: please_come_aftersome answer: coming and nocoming and notcoming question_to_answer: y $ while read line1 && read line2 && read line3; do if `grep -q "notcoming" <<< $line2`;then echo $line1 $'\n'$line2; fi; done < file.txt text_one: please_come answer: coming and notcoming text_three: please_come_aftersome answer: coming and nocoming and notcoming Quote
Kumaravaarma Posted April 27, 2020 Author Report Posted April 27, 2020 On 4/24/2020 at 5:45 PM, kumar4world said: @Kumaravaarma grep -E and egrep are same this will work $ cat file.txt text_one: please_come answer: coming and notcoming question_to_answer: y text_two: plese_donot_come answer: nocoming question_to_answer: y text_three: please_come_aftersome answer: coming and nocoming and notcoming question_to_answer: y $ while read line1 && read line2 && read line3; do if `grep -q "notcoming" <<< $line2`;then echo $line1 $'\n'$line2; fi; done < file.txt text_one: please_come answer: coming and notcoming text_three: please_come_aftersome answer: coming and nocoming and notcoming Thanks kaka. btw &&, <<, $ parameters emm chestadhi. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.