removing a line containing a pattern in sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting removing a line containing a pattern in sed
# 1  
Old 04-20-2008
removing a line containing a pattern in sed

i need to use sed to remove an entire line containing a pattern stored in a variable say $var1
this var1 will be a URL and will therefore contain slashes

any help would be greatly appreciated
# 2  
Old 04-20-2008
The pattern can be delimited by any character, the syntax is :
Code:
\cregexc

For example (with the character °)
Code:
sed 'https://www.unix.com°d'

If the regex is store in the variable var, you can do (note \ must be doubled because it's inside ") :
Code:
sed "\\°${var}°d"

Jean-Pierre.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl removing line match with pattern in column

Hi, I have log like this: ... (1 Reply)
Discussion started by: justbow
1 Replies

2. Shell Programming and Scripting

Perl removing line match with pattern in column

Hi, I have log like this: ... (1 Reply)
Discussion started by: justbow
1 Replies

3. Shell Programming and Scripting

Removing spaces from line matching a pattern

Hi, I want to remove the spaces from all the lines matching a particular pattern from my file. For instance in file abc.txt I have following data. Header,This is the header 111,this is 1st record 222, this is 2nd record 333, this is 3rd record Footer,3 records found Footer,111222333 ... (5 Replies)
Discussion started by: decci_7
5 Replies

4. Shell Programming and Scripting

Removing a pattern in a line

Dear team, I have a file curve.csv which is generated from oracle and each line has a comment associated with it, I want to get rid of this comment, can you please suggest me a command as how to do it Eg, cat curve.csv /*data for today curve*/ /*data for text1*/ this is the header /*data... (6 Replies)
Discussion started by: infyanurag
6 Replies

5. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

6. Shell Programming and Scripting

Deleting pattern without removing line

I am trying to delete a pattern without removing line. I searched a lot in this forum and using those I could come up with sed command but it seems that command does not work. Here's how my file looks like: 1 ./63990 7 1171 ./63990 2 2425 ./63990 9 2539 ./63990 1 3125 ./63990 1 10141... (7 Replies)
Discussion started by: shoaibjameel123
7 Replies

7. Shell Programming and Scripting

sed removing until end of line

All: Can somebody help me out with a sed command, which removes the the first occurance of ')' until the end of the line If I have the following input ... (5 Replies)
Discussion started by: BeefStu
5 Replies

8. UNIX for Dummies Questions & Answers

Removing end of line using SED

Hello Friends, How can I remove the last two values of this line using sed John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638:9/3/90:45900 The result should look like this: John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638 (3 Replies)
Discussion started by: humkhn
3 Replies

9. Shell Programming and Scripting

Replacing or removing a long list of pattern by using awk or sed

Input: >abc|123456|def|EXIT| >abc|203456|def|EXIT2| >abc|234056|def|EXIT3| >abc|340056|def|EXIT4| >abc|456000|def|EXIT5| . . . Output: def|EXIT| def|EXIT2| def|EXIT3| def|EXIT4| def|EXIT5| . . My try code: (9 Replies)
Discussion started by: patrick87
9 Replies

10. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies
Login or Register to Ask a Question