Re: Need refinement to minimal-bash-script



problems@gmail <problems@gmail>:
With previous help from contributors to this group, I've got
a script which reads the URLs from a file and dumps/appends
the [lynx] contents to a file, for reading off-line.
Here's the script-line which has been working well:
#
#!/bin/bash
for url in `cat NewsLst`; do lynx -dump "$url" >> accumNewsLst; done

So now I want to avoid having to add the URL as a header and
a "<><><>..." as a end-marker for each fetch which is appended to
the accumulating-file. Here's my failed attempt:

for url in `cat urls.txt`; do
echo "<><><><><>" >> accumulation;
"$url" >> accumulation;
echo " == blank line ==" >> accumulation;
lynx -dump "$url" >> accumulation; done

for url in `cat urls.txt`; do
echo >> accumulation # bare echo == newline
echo "$url" >> accumulation # added "echo"
echo >> accumulation
lynx -dump "$url" >> accumulation
echo >> accumulation
echo '<><><><><>' >> accumulation # single ticks.
done

BTW, bash also has printf, which may help consolidate the mess.

printf '\n%s\n' $url >> accumulation

replaces the first three echos.


--
Any technology distinguishable from magic is insufficiently advanced.
(*) http://blinkynet.net/comp/uip5.html Linux Counter #80292
- - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me.
.



Relevant Pages

  • Re: HELP! Scripting newbie question.
    ... printf "File: $file\n" ... There is nothing in your script to do the expand of the $1. ... insert a test by doing an echo $list or echo $1 in your srcipt to ...
    (comp.unix.solaris)
  • Re: Script to find all soft links problem
    ... On 9 Dec 2007 05:04:04 GMT, Steffen Schuler ... Don't forget quoting and use printf instead of echo. ... your script is a valid POSIX shell script --- no need of bash. ...
    (comp.unix.shell)
  • Re: Need refinement to minimal-bash-script
    ... a script which reads the URLs from a file and dumps/appends ... echo>> accumulation ... Allow me to suggest adding "-nolist" to the lynx command. ...
    (comp.os.linux.misc)
  • Re: decimal number type
    ... I'm using this simple script: ... instead of echo, but be extremely careful when adding leading zeroes if ... the result will ever be processed by a shell script or any program that ... printf "%03d\n" 022 ...
    (comp.unix.solaris)
  • Re: Appending to script output while executing
    ... > thinking I need to spawn another process or call a separate script? ... # kill the dial ... If you do not have printf, try echo -n. ...
    (comp.unix.shell)