Delete all lines of a file containing a regex pattern using sed. For example you can delete all commented lines of a default configuration file. Take a look on my basic regex cheat sheet
1 |
sed -i '/regexPattern/d' path/to/file1.log |
Delete all lines of a file containing a regex pattern using sed. For example you can delete all commented lines of a default configuration file. Take a look on my basic regex cheat sheet
1 |
sed -i '/regexPattern/d' path/to/file1.log |
Replace a string with a new one in all files using sed and xargs
1 2 3 |
oldstring="some_string_to_search" newstring="new_string_to_replace" grep -rl $oldstring /path/dir/ | xargs sed -i s@$oldstring@$newstring@g |
Comment specific line using sed command can be used to configuration files …
1 |
sed -i '123 s/^/#/' filename |