When I do enter those commands individualy, I get the results I want:
cat /var/log/apt/history.log | grep 'apt install' > installation.txt
grep -v "nvidia" installation.txt > tmpfile && mv tmpfile installation.txt
awk -F"ll " '{print $2}' installation.txt > temp1
sed -n '/--/!p' temp1 > temp2
sed -n '/-f/!p' temp2 > installation.txt
But I do not find how to combine those ...
Here some the tests I made without the nvidia search to try to understand where it goes wrong first:
cat /var/log/apt/history.log | grep 'apt install' > file | awk -F"ll " '{print $2}' file > temp | sed -n '/--/!p' temp > file | sed -n '/-f/!p' file > installation.txt
cat /var/log/apt/history.log | grep 'apt install' > file | awk -F"ll " '{print $2}' file | awk -F"ll " '{print $2}' file | sed -n '/--/!p' file | sed -n '/-f/!p' file
cat /var/log/apt/history.log | grep 'apt install' > file | awk -F"ll " '{print $2}' file > temp | sed -n '/--/!p' temp > file | sed -n '/-f/!p' file > installation.txt
How can I combine these operations?
I want to be able to export the packages I've installed and include the function in script I made available on github.
I need to use this command in my packages.sh script.
grep
to remove lines matchingnvidia
, but then usedsed
to remove line containing--
or-f
... I wonder if it was due to the initial dash?grep -v -e -- -e -f
would have worked. An even better answer may have surfaced if you had described what the commands actually did (or what you hoped to achieve). – Kusalananda Jan 27 '23 at 21:06