Say you have records in a text file which look like this:
header data1 data2 data3
I would like to delete the whole record if data1 is a given string. I presume this needs awk which I do not know.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Awk can handle these multiline records by setting the record separator to the empty string:
You can save this in a file (eg
remove.awk) and execute it withawk -f remove.awk data.txt > newdata.txtThis assumes your data is of the format:
If there are no blank lines between the records, you need to manually split the records (this is with 4 lines per record):