Good afternoon,
I am trying to create a bash script that cleans data output files. Files are as follows:
/path/ /path/to /path/to/keep /another/ /another/path/ /another/path/to /another/path/to/keep
I would like to end up with:
/path/to/keep /another/path/to/keep
I want to cycle through the lines of a file, checking the next line to see if it contains the current line, and if so, delete the current line from the file. Here is my code:
for LINE in $(cat bbutters_data2.txt) do grep -A1 ${LINE} bbutters_data2.txt if [ $? -eq 0 ] then sed -i '/${LINE}/d' ./bbutters_data2.txt fi done
source share