Remove specific line of files in linux [closed]

1

I need to remove a particular line in a file crontab ex:

* * * * * root /home/linaro/funcao1.sh
* * * * * root /home/linaro/funcao3.sh
* * * * * root /home/linaro/funcao4.sh
* * * * * root /home/linaro/funcao5.sh

I would like to delete the line

* * * * * root /home/linaro/funcao4.sh

Remembering that this file is not in crontab it will be imported according to the script

I tried to use sed but my deficiency in regular expressions did not allow me to make it work

sed '* * * * * root /home/linaro/funcao4.sh' /home/linaro/mycron.txt
    
asked by anonymous 07.11.2018 / 18:40

3 answers

2

Use sed -i to replace in the file itself:

sed -i '/* * * * * root \/home\/linaro\/funcao4.sh/d' arquivo
    
08.11.2018 / 11:31
2

I could use grep in the form:

grep -v "* * * * * root /home/linaro/funcao4.sh" /etc/crontab > /home/usuario/mycron
mv /home/usuario/mycron > /etc/crontab
    
22.11.2018 / 11:47
1

I was able to solve ^^

sed '/* * * * * root \/home\/linaro\/funcao4.sh/d' /etc/crontab  > /home/linaro/mycron
cat /home/linaro/mycron > /etc/crontab
rm -rf mycron
    
07.11.2018 / 18:57