Bash things I always need to look up.
if test ! $(which jq) then echo "Looks like you don't have jq installed. Installing jq..." brew install jq echo "...jq installed!" else echo "You've already installed jq. Cool!" fi
for site in 1202859 1202862 1201051 1207663 1228567 1213504 1224728 1229567 1239206 do echo "iteration for $site" done
- When using a
$variable, you have to use “, not ‘ !
- Variable assignment from the results of another command:
- Array assignment from the results of another command: `array_name=($(command))
- -o for saving to a file
-rto remove quotes around the data. raw.
| @shfor transforming arrays into space separated strings
# Select all children of the data object and extract the value of the id keys | jq '.data.id' # Select the first element of the data object and return the value of the filesystemBackupId key, raw/no quotes | jq -r '.data.filesystemBackupId'
Transformations! Replacements, changing case, https://linuxhint.com/bash_tr_command/
| tr '\n' ' ') to replace new lines with spaces.
nohup (No Hang Up) is a command in Linux systems that runs the process even after logging out from the shell/terminal.
nohup command [command-argument ...]
wget can download recursively!
wget -r -1 0 https://site.com/….
Set the maximum number of subdirectories that Wget will recurse into to depth. In order to prevent one from accidentally downloading very large websites when using recursion this is limited to a depth of 5 by default, i.e., it will traverse at most 5 directories deep starting from the provided URL. Set ‘-l 0’ or ‘-l inf’ for infinite recursion depth.https://www.gnu.org/software/wget/manual/wget.html#Recursive-Retrieval-Options