Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
read ANSWER; if [ "x$ANSWER" == "xyes" ]; then sed .......; fi
thanks...
but i ran into another prob.
i need to grep a part of an url, before i can SED it...
but with this doesnt work:
grep " onMouseOver=\"window\.status='abc, def in \$var en ghi\.'; return true\"" * -R
the complet line where the url in a php file look like this:
echo " | <A HREF=\"http://www.domain$var.com/dir/file_nl.php?v1=$var&v2=$var2&file=abc\" onMouseOver=\"window.status='abc, abc in $var en abc.'; return true\">abc in $var</A>";
That's a pretty nasty string to be grepping for. Try using fgrep (or grep -F) instead of grep. I predict you'll still have to play around with escaping a bit to get it to match.
That, or you could be extremely lazy, and replace anything which you would have to escape with a '.', e.g.
Code:
grep " onMouseOver=.window.status=.abc, def in .var en ghi... return true."
It's possible it will match things you don't want it to, but under the circumstances, I don't think it'll be a problem. I wouldn't use this for mission critical code, though.
for f in `find . -type f`;
do if grep "http://www.$domain.com/dirs/file_nl.php?loc=$Var&var=$var&file=file" "$f";
read ANSWER; if [ "x$ANSWER" == "xyes" ];
then sed -i
's/http:\/\/www.$domain.com\/dirs\/file_nl.php?loc=$Var&var=$var&file=file
/http:\/\/www.$domain.com\/nl\/dirs\/$var\//g'
"$f";
fi;
done
Your sed command looks OK in your last post - backslashes (\) to escape characters. To be completely accurate, you should escape all the '.'s in the first part of the sed expression, but it shouldn't be a problem here.
for f in `find . -type f`;
do if grep "http://www.$domain.com/dirs/file_nl.php?loc=$Var&var=$var&file=file" "$f";
then
read ANSWER; if [ "x$ANSWER" == "xyes" ];
sed -i
's/http:\/\/www\.$domain\.com\/dirs\/file_nl\.php?loc=$Var&var=$var&file=file
/http:\/\/www\.$domain\.com\/nl\/dirs\/$var\//g'
"$f"; fi; done
with this i get another error:
-bash: syntax error near unexpected token `fi'
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.