How to replace in an bash script variable?
This topic is a waste of time, no solution to the question.
Hello, im having urlfile and each url in it contains $ip variable which i need to replace by actual IP that is actual for the present "while loop" cycle: Code:
while read ip;do http://domain1.com/?something&?ipp=$ip http://domain2.com/?ipaddr=$ip&something=something http://domain2.com/?a=lldd?ipaddr=$ip#something But i dont know what is the clever/low resource usage/low amount of code way to replace that $ip variable inside the URLs that i have either in urlfile or in variable that i populate somehow out of urlfile? Thanks in advance ---- Update: Solution for my case: Quote:
|
Quote:
A brief Google search turns up lots. From just ONE is this sample: Code:
saveIFS="$IFS" |
yes, please anyone else how to do it please?
|
Quote:
|
Sorry, im newbie i do not understand your copy paste "solutions" that do not fits my case. That is why im asking for other people oppinion. I ask you to stop answering in my topics. If you do not provide solutions and instead you will be bashing offtopic & wasting my time and other readers time, i will just report your post.
|
Did you post the entire urlfile? And is it exactly as shown? Does the IP file and url file correspond one for one? Or as in your loop do you apply each IP to every URL?
|
Quote:
So far i have 3 URLs in urlfile and there are parts of that URLs, parts where should be IP assigned..: ...=$ip ...=$ip&... ...=$ip&... |
And the other questions?
Does the IP file and url file correspond one for one? Or as in your loop do you apply each IP to every URL? |
Quote:
So for each IP i will process all 3 URLs, and i need to replace the $ip variable in them by actual IP (actual for that "while loop" i mentioned in my initial post). Is it clearer please? |
Quote:
That, is how you stop being a 'newbie' and start to be able to do something for yourself. Quote:
Quote:
Quote:
Since you're a 'newbie' (who has been here 3 years), you probably haven't read the question guidelines. Quoting the relevant parts here, bolded parts are mine: Quote:
Quote:
|
I think string expansion by using the eval command should work but there are many ways.
I can not provide examples at the moment |
Quote:
In the first reply, I gave the OP something that would work, but they flat out said they didn't want to modify anything, and wanted a solution to 'fit their case' |
Things you do in a public forum:
- Be kind to each other - Be on topic - When you don't understand an answer ask for clarification, in the same way: If the question is not clear enough ask for clarification - Use all the options the forum software provides you. This includes the Ignore List function. Things you never do on a public forum (and even real life): - releasing private messages into public without explicit permission from all involved parties. There is a reason they are called private messages. If you feel you are harassed, insulted, ..., in private messages contact a mod or Jeremy. |
Please anyone else know the solution for this (see initial mesaage)? I cant believe it can be so difficult to come with simple, clever solution.
|
|
All times are GMT -5. The time now is 09:52 AM. |