ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I think you need to provide a little more information for it to be useful to others. Your first post would seem flawed.
If we can assume that the domain variable has the string 'pornotane.org' in it I do not believe sed will delete a line not containing that string ie. 'hdportane.org'.
Would you mind explaining a little further the original problem?
I was also curious about the 3 sets of quotes?? Is that just a typo?
Lastly, the -e is not required for only a single entry or was this culled from a larger sed statement and perhaps the cause of the original issue?
first, no it's not related to -e and the command is the from time i was trying anything to handle problem. Don't even remember what -e parameter is doing.
second, it is working as following
more file1.txt | while read LINE
do
domainLine=$(echo $LINE | awk '{printf $2}')
for domain in $domainLine
do
# echo $domain
grep $domain file
# sed -i "/$domain/d" file
gsed -i "/\b$domain\b/d" file
done
done
Please use [code][/code] tags for your code snippets.
I would add that as you are parsing an entire file, without seeing its contents what could assume that both domains are listed in the file and hence why you were removing unwanted lines.
Remembering that a regex does not pick and choose what it matches and no addition of boundaries would assist in the issue.
Lastly, please remember to select he SOLVED option under thread tools if your solution has been found.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.