
On 13.01.14 17:44, Andrew McGlashan wrote:
The following is neater and cleaner:
#!/bin/bash
( curl -Ss "https://googledrive.com/host/0B2KTxndVFSKuSjZKTDRaTlpJcmM/"| \ sed 's`<a href`\n<a href`g'| \ grep '^<a href'| \ awk -F\" '{print "wget -c \"https://googledrive.com"$2"\""}' ) | tee y.y chmod +x y.y ./y.y rm y.y
Ah, that is much easier to read. Just one annoying suggestion from a backseat driver; The following are equivalent: grep '^foo' | \ awk '{print "wget -c bar "}' and awk '/^foo/ {print "wget -c bar "}' I.e. The core of awk is that it is a line processor which runs blocks of C-like text processing code against those input lines which match a set of regex or literal text triggers. Also, to simplify quoting, inclusion of shell variables can be done with: awk -F '/^foo/ {print "wget -c bar '$2' "}' A simple demo of that: $ x=fred $ echo | awk '{print "$x is '$x'"}' $x is fred IIUC, the sed line is just adding line breaks at href tags. Setting RS to a regex (in awk) would allow awk to see the input as lines broken only at those tags, obviating the need for sed as well. Hopefully that's interesting and/or useful. Erik -- The future is a race between education and catastrophe. - H. G. Wells