How to modify a file using awk?

awk '/<ul>/ {ul++} ul == 6 { getline } 1' /var/www/html/INFOSEC/english/test.html 

If I run this line of code, the shell will not help me modify the file; instead, it displays the result only in the shell. Can anyone help? thanks

+6
source share
1 answer

The simplest solution is to simply send the output to a file; you can copy the file in advance so as not to overwrite the file you are reading (which otherwise could lead to unwanted behavior).

 cp test.html test.html.orig awk 'your awk script here' test.html.orig >test.html # and then optionally remove the copy: rm test.html.orig 
+12
source

Source: https://habr.com/ru/post/893130/


All Articles