Using wget to recursively fetch a directory with arbitrary files in it

You have to pass the -np/–no-parent option to wget (in addition to -r/–recursive, of course), otherwise it will follow the link in the directory index on my site to the parent directory. So the command would look like this: wget –recursive –no-parent http://example.com/configs/.vim/ To avoid downloading the auto-generated index.html files, use the -R/–reject option: wget … Read more

How to read a file into a variable in shell?

In cross-platform, lowest-common-denominator sh you use: #!/bin/sh value=`cat config.txt` echo “$value” In bash or zsh, to read a whole file into a variable without invoking cat: #!/bin/bash value=$(<config.txt) echo “$value” Invoking cat in bash or zsh to slurp a file would be considered a Useless Use of Cat. Note that it is not necessary to … Read more

Shell command to sum integers, one per line?

Bit of awk should do it? awk ‘{s+=$1} END {print s}’ mydatafile Note: some versions of awk have some odd behaviours if you are going to be adding anything exceeding 2^31 (2147483647). See comments for more background. One suggestion is to use printf rather than print: awk ‘{s+=$1} END {printf “%.0f”, s}’ mydatafile

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)