Delete lines using awk
Here’s how to delete a line from a file using awk.
<pre lang="bash">
awk '!/Redhat/' sample.txt > sample.tmp && mv sample.tmp sample.txt
The command above looks for ‘Redhat’ in a file and removes that line from the file.
You can add the line in the crontab to run at reboot if you like.
<pre lang="bash">
crontab -e
<pre lang="bash">
@reboot awk '!/Redhat/' sample.txt > sample.tmp && mv sample.tmp sample.txt