Results 1 to 10 of 10
Hi
I need to replace this word https://$test with $test .... I have tried this using the sed command like sed -i 's/https://$test/$test/g' test.php .. but I am not getting ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 04-08-2009 #1Just Joined!
- Join Date
- Mar 2009
- Location
- Hyderabad
- Posts
- 10
Command to Find and Replace the word
Hi
I need to replace this word https://$test with $test.... I have tried this using the sed command like sed -i 's/https://$test/$test/g' test.php.. but I am not getting the desired output....
Please can anyone help me how to do this.... Thanks.
- 04-08-2009 #2
You were almost there with your sed command but you need to escape your forward slashes in the http:// so that sed doesn't get confused by them. You simply do this by preceding each one with a backslash like this:
Code:sed -i 's/https:\/\/$test/$test/g' test.php
Linux User #453176
- 04-08-2009 #3Just Joined!
- Join Date
- Mar 2009
- Location
- Hyderabad
- Posts
- 10
Thank you very much.. This command worked for me..
and I have one more question .. Can u pls say how to check the files list having this variable $test... I mean command to search the word in list of scripts.. I used find command find *.php -name $test but not working..... Thanks.
- 04-08-2009 #4
Try using grep instead:
Code:grep $test
Linux User #453176
- 04-08-2009 #5Just Joined!
- Join Date
- Mar 2009
- Location
- Hyderabad
- Posts
- 10
Sorry, Not able to find the result from the above ... getting the msg like "Usage: grep [option]..pattern [file]".. but in this directory I am having the scripts using the $test variable.
- 04-08-2009 #6
Sorry, try:
Code:grep $test *.php
Linux User #453176
- 04-08-2009 #7Just Joined!
- Join Date
- Mar 2009
- Location
- Hyderabad
- Posts
- 10
I have executed the above..But not getting any o/p.
..../TEST # grep $test *.php...
- 04-08-2009 #8
You need to escape the $ symbol sorry. Also if you just want a list of filenames use the -l argument:
Code:grep -l \$test *.php
Linux User #453176
- 04-10-2009 #9Just Joined!
- Join Date
- Mar 2009
- Location
- Hyderabad
- Posts
- 10
Thank You.
- 04-10-2009 #10


Reply With Quote

