sed delete line match

Use d option at the end of sed command string for deleting line of matches.
sed -i "" "s/matching_pattern/,+1 d" file.txt #+1 defines number of lines
# to delete after matching line

4.33
3
Rezaldo 105 points

                                    sed '/pattern to match/d' ./infile

4.33 (3 Votes)
0
4.25
4
Ian Bartlett 150 points

                                    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 #

4.25 (4 Votes)
0
3.71
7
Alisonh726 90 points

                                    # You can use awk's field separator (-F) following way:
$ cat file
google.com/funny
unix.stackexchange.com/questions
isuckatunix.com/ireallydo

3.71 (7 Votes)
0
0
7
Oscar Ng 70 points

                                    Use d option at the end of sed command string for deleting line of matches.
sed -i "" "s/matching_pattern/d" file.txt

0
0
4
3
Je2018 105 points

                                    Use d option at the end of sed command string for deleting line of matches.
sed -i "" "s/matching_pattern/d" file.txt

4 (3 Votes)
0
3.9
10
Collin Day 110 points

                                    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 #

3.9 (10 Votes)
0
4.14
7

                                    sed '/pattern to match/d' ./infile

4.14 (7 Votes)
0
4.17
6
Macit 90 points

                                    # You can use awk's field separator (-F) following way:
$ cat file
google.com/funny
unix.stackexchange.com/questions
isuckatunix.com/ireallydo

4.17 (6 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
sed delete after match sed command to remove string after character sed command to remove string after pattern sed delete line containing regex sed delete lines between matches delete a line match pattern sed delete lines that contain character sed search character and delete line sed sed remove particular line sed remove line with pattern sed delete multiple lines after pattern remove line starting with sed sed delete line match sed remove line if match pattern sed remove character at beginning of line match variable sed delete line containing string sed delete lines containing sed delete a match sed remove line pattern match delete sed before matching lines delete sed before lines sed remove line that contains string sed how to delete lines starting with sed delete everything match to end of line sed delete line above match sed remove line containing string sed delete line with matching text delete line containing string sed sed delete line no delete lines before match sed sed remove all the string after a match sed delete lines plus some that match regex sed remove before character sed remove lines before and after pattern is matched sed remove 3 lines after pattern is matched sed delete line matching variable sed delete matching line sed delete line matching pattern sed delete next line after match delete empty lines sed sed remove a matching line sed remove lines after match sed remove line that matches sed delete line after match sed delete line matching regex sed delete two lines after a match sed is deleting all lines above match why? sed delete lines after matching pattern sed delete -x number of lines after matching pattern sed remove characters after match sed delete if matches in next line delete two lines after match sed sed remove items after match sed delete line containing match sed remove line with matching pattern sed remove line contaning string sed remove line matching pattern sed delete line and x lines following it linux sed delete line sed delete lines deleting a line from a file bash remove lines from text file if it contains string bash remove line from file containing string find and delete lines from file bash remove lines from file that contain string linux remove line from file containing string remove line containing word linux grep delete lines containing string ubuntu sed delete line containing match shell replace everything after string sed delete all lines that don't match remove line after string string bash remove all lines containing string shell script to remove any line contanint regex search pattern sed delete line containing sed delete line above matched line linux delete line before match sed delete line after matching pattern sed remove line containing delete line with match sed remove line with match sed delete line before match remove line after with match command remove line with match command sed remove line after match sed remove line with pattern from file sed remove line with pattern match sed delete line with matching pattern sed delete line with matching string sed delete line with match bash remove everything after character from each line sed delete rest of line after match linux sed command delete rest of line after match delete string after character in each line linux
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source