Relative Content

Tag Archive for linuxbashawksedgrep

Find 1st occurrence of of string after you find the first match Liunx Bash

I know grep -C -A -B commands – but I have file that I cannot use any of these options on –
I need to find a pattern/match lets say XYZ once I find the XYZ i need to find first occurrence on YYY above it and assign that to a variable . In example below I want to find the “JELLY” assign it to $VAR1 and then look for the first line that has REC in it and in this case assign the value fish2 to $VAR2 — This is a huge file and each section length starting with REC is different in number line it contains ? Please assist .

How to find strings in multiple lines of txt file then add all to new csv line

I have thousands of txt files that were converted from emails that included a “Contact Us” form. I need to find/select strings in the second “column”, but the number of lines to start each email are variable. It seems that the columns are tab delimited. To boot, the last field in the contact form spans multiple lines and some of the emails have pipe symbols “|” that seem to have been created since I used html2text to convert these to txt files. How can I extract the values of the “First Name”, “Last Name”, and “Long Text” fields? Ultimately these will be added as a new line in a csv.