Loading...

remove absolute path using sed command

Answer #1 100 %

Try this,

$ sed '/^include /s/.*//g' file.txt
abc...

some text

It remove all the texts in a line which starts with include. s means substitute. so s/.*//g means replace all the texts with null.g means global. The substitution will be applied globally.

OR

$ sed '/^include /d' file.txt
abc...
some text

d means delete.

It deletes the line which starts with include. To save the changes made(inline edit), your commands should be

sed -i '/^include /s/.*//g' file.txt
sed -i '/^include /d' file.txt
Tags: bashsed

You’ll also like:


© 2022 CodeForDev.com -