Answers for "sed remove line containing"

4

sed remove line containing

sed '/pattern to match/d' ./infile
Posted by: Guest on December-23-2020
2

delete a line starting with sed

# Delete all lines starting with '#'
$ sed -i '/^#/d' filepath
Posted by: Guest on July-07-2020
2

delete line in sed

# -i here update the file, try with and without -i, 
sed -i -e "/your_pattern/d" file 
sed -i -e "/your_pattern/,+2 d" file  # 2 lines after the pattern
sed -i -e '5,5d"  # remove 5th line
Posted by: Guest on June-15-2021
0

sed delete line before match

Use d option at the end of sed command string for deleting line of matches.
tac | sed -i "" "s/matching_pattern/I+1 d" file.txt | tac #
Posted by: Guest on December-17-2020
0

sed remove line

$ sed 's|http://||' <<EOL
http://url1.com
http://url2.com
http://url3.com
EOL
Posted by: Guest on June-21-2021
-1

remove line with pattern

Use d option at the end of sed command string for deleting line of matches.
sed -i "" "s/matching_pattern/d" file.txt
Posted by: Guest on October-24-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language