| | |
Error using sed.
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 42
Reputation:
Solved Threads: 0
I am trying to delete any line of text that contains "$npname" and the word "in." The script works if $npname is only one word, but if it is more than one work I get "error: unterminated address regex" How can I fix this?
Shell Scripting Syntax (Toggle Plain Text)
sed '/'$npname'.*in/d' parts.txt > parts.tmp
0
#2 26 Days Ago
Why not use
grep ? Shell Scripting Syntax (Toggle Plain Text)
sk@svn:/tmp/daniweb$ npname="part" sk@svn:/tmp/daniweb$ egrep -vi ".*${npname}.*in.*" parts.txt sk@svn:/tmp/daniweb$ npname="part part" sk@svn:/tmp/daniweb$ egrep -vi ".*${npname}.*in.*" parts.txt part1.in part3.in sk@svn:/tmp/daniweb$ cat parts.txt part1.in part part.in part3.in
1
#3 25 Days Ago
•
•
•
•
I am trying to delete any line of text that contains "$npname" and the word "in." The script works if $npname is only one word, but if it is more than one work I get "error: unterminated address regex" How can I fix this?
Shell Scripting Syntax (Toggle Plain Text)
sed '/'$npname'.*in/d' parts.txt > parts.tmp
sed "/$npname.*in/d" parts.txt > parts.tmp
•
•
Join Date: Nov 2009
Posts: 42
Reputation:
Solved Threads: 0
0
#4 25 Days Ago
•
•
•
•
It makes a difference the quotation scheme.
sed "/$npname.*in/d" parts.txt > parts.tmp
Shell Scripting Syntax (Toggle Plain Text)
sed '/'"$npname".*in'/d' parts.txt > parts.tmp
0
#5 24 Days Ago
That looks strikingly similar to the code Aia provided 
Please mark this thread as solved if you have found an answer to your question and good luck!

Please mark this thread as solved if you have found an answer to your question and good luck!
![]() |
Similar Threads
- Help with while loop and sed (Shell Scripting)
- How to delete last three lines in file (Shell Scripting)
- Query regarding file (C++)
- Getting project error: ( probably due to code) (C++)
- sed command not running (Shell Scripting)
- sed problem (Shell Scripting)
- how can i display data in textbox from choosen dropdown menu? (VB.NET)
- how to add a sound button in vb.net? (VB.NET)
- Error in script (Shell Scripting)
Other Threads in the Shell Scripting Forum
- Previous Thread: Software version upgrade using shell scripting
- Next Thread: Using user input in BASH array.
| Thread Tools | Search this Thread |






