I want to catch the word that is after "on" in several lines at a file, and if the word appears already in the file, I want to skip it. I tried to do so:
#!/bin/bash
echo "" > missig_packages.txt
cat log_file.txt | grep depends > dependsLog.txt
function createListOfPackages {
if grep "$1" missig_packages.txt; then
continue
else
echo "$1" >> missig_packages.txt
fi
}
while read line; do
package=`cat dependsLog.txt | cut -d" " -f5`
createListOfPackages $package
done < dependsLog.txt
The file dependsLog.txt contains lines like this:
libgcc1:amd64 depends on **gcc-4.9-base** (= 4.9.1-0ubuntu1); however:
cinder-volume depends on **cinder-common** (= 1:2015.1.1-0ubuntu2~cloud2);
python-cryptography depends on **python-cffi**.
python-pycadf depends on **python-netaddr**.
How can I grep the words between ** and ** (which are not themselves in the text)? Each line begins with "".
missing_packages.txt(with an 'n') instead?