Re: Bash 1-liner needs refining.

Re: Bash 1-liner needs refining.

am 16.11.2007 00:15:32 von Kees Theunissen

Martin Klar wrote:

(long command broken up in short strings for readability)
> for url in `cat linksURL`; do
> a=$(echo "$url" | \
> sed "s/^/http\:\/\/groups.google.com\//" | \
> sed "s/$/\?Ink\=sg\&hl\=en/");
> elinks -dump "$a" >> accumelinks;
> done

Very expensive.
This will use one "echo" two pipes and two external
"sed" processes just to prepend and append some strings to
a variable.

What is wrong with something like:

cat linksURL | \
while read URL ; do
elinks -dump "http://groups.google.com/${URL}?Ink=sg&hl=en" \
>> accumelinks ;
done


Regards

Kees.

--
Kees Theunissen.

Re: Bash 1-liner needs refining.

am 16.11.2007 01:03:23 von Ed Morton

On 11/15/2007 5:15 PM, Kees Theunissen wrote:
> Martin Klar wrote:
>
> (long command broken up in short strings for readability)
> > for url in `cat linksURL`; do
> > a=$(echo "$url" | \
> > sed "s/^/http\:\/\/groups.google.com\//" | \
> > sed "s/$/\?Ink\=sg\&hl\=en/");
> > elinks -dump "$a" >> accumelinks;
> > done
>
> Very expensive.
> This will use one "echo" two pipes and two external
> "sed" processes just to prepend and append some strings to
> a variable.
>
> What is wrong with something like:
>
> cat linksURL | \
> while read URL ; do
> elinks -dump "http://groups.google.com/${URL}?Ink=sg&hl=en" \
> >> accumelinks ;
> done
>
>
> Regards
>
> Kees.
>

Very expensive ;-).
This will use one "cat" and one pipe....

Here's the equivalent:

while read URL ; do
elinks -dump "http://groups.google.com/${URL}?Ink=sg&hl=en" \
>> accumelinks ;
done < linksURL

Regards,

Ed.