[sed/awk] find info and replace

Hi :slight_smile:
I have some problems with "FOR"...

I have a text file in this format:

name1
www.link1/random_number
name2
www.link2/random_number
name3
www.link3/random_number
...

(Names and info changes)

Now, I need:

For each link found download the related page.

So:

  • For each link
  • execute command wget -options www.link/url_variable | (sed commands to find info)
  • for each result insert the result under the right name.

I made a sed command for obtain info that I need from the page.
So this is not a problem.

The result should be like this:

name1
some info found in www.link1/random_number

name2
other info find in www.link2/random_number

name2
other info find in www.link3/random_number

thanks in advance :wink:

That's not surprising. The shell does not have a command named "FOR". It does have "for".

Why would you use "for" to read a file?

while read name; read line
do
  printf "%s\n" "$name"
  wget -O - [other options] "$line" | sed ...
  echo
done < "$FILE"

You are right @cfajohnson!!!

"WHILE" time! :slight_smile:

Thank you!

Best Regards!

So... a little help...

while read name; read line
do
  printf "%s\n" "$name"
  wget -O - [other options] "$line" | sed ...
  echo
done < "$FILE"

How can view this output inside zenity?

solved, with a pipe :slight_smile:

... | zenity --text-info

very simple :slight_smile: