I have a directory
dash7/ which contains multiple text files and I want to remove all lines containing the string
D PRINT from all those files.
How can I do that easily from the command-line?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
You can achieve this rather easily with
sed which can happily look into multiple files
sed '/D PRINT/d' dash7/*
/D PRINT/find a line with
ddelete the line
dash7/*look in all the files in the directory
dash7(add the path to it, for example
To actually change the files rather than print the edited text in the terminal, you need to add the
-i flag to modify in place
sed -i '/D PRINT/d' dash7/*