ls /data/<snip>/pdfs/
returns Input/Output Error
on some pdfs/path/page/2, /path/page/3, ...
curl
to inspect page at a lower level, notice temporary redirects$ grep 'searchstring' files/* | less
$ true || echo 'never gets here'
$ false && echo 'never gets here'
$ echo 'this now an error message' 1>&2 | grep -v error
this is now an error message
!$ # last argument to last command
$ cat /dir
cat: /dir/: Is a directory
$ cd !$
cd /dir
$ pwd
/dir
$ for x in 1 2 3; do echo $x; done # Use seq for longer sequences
1
2
3
$ var='this is a var'; echo ${var//this is } # Deletes 'this is '
a var
$ ls -l `which bash`
-rwxr-xr-x 1 root root 1029624 Nov 12 15:08 /bin/bash
$ set -a blocks
$ blocks="10.0.0.0/24"
$ set -a ips
$ ips=`fping -g 10.0.0.0/24 2>&1 | grep unreachable | tr \\ \\n`
$ for ip in $ips; do
$ nmap -p 22 $ip && ips=`echo ${ips//$ip} \
| tr -s \\n`
$ done
$ echo $ips
name () {
# code goes here
}
You should know the following:
Variable | Meaning |
---|---|
$* |
All arguments passed |
$? |
Return code of last command run |
"$@" |
All arguments passed as a list |
$CDPATH |
Colon-delimited list of places to look for dirs |
$HOME |
Location of user homedir |
$IFS |
Internal Field Seperator |
$OLDPWD |
Previous PWD |
Variable | Meaning |
---|---|
$PATH |
Colon-delimited list of places to find executables |
$PWD |
Present Working Directory |
$SHELL |
Path to running shell |
$UID |
User ID |
$USER |
Username |
You should also read the EXPANSION section of the bash man page.
awk
cat
cd
cut
grep
ls
lsw
lsx
mtr
nc/netcat
pwd
rev
sed
seq
sort
tar
tr
uniq
w
wc
Every char in $IFS
bash considers a seperator between words.
#!/bin/bash
var1=1-2-3
var2=2+3+4
IFS=-
echo $var1
echo $var2
IFS=+
echo $var1
echo $var2
The advanced bash scripting guide is very useful.
In particular, part 5 contains a lot of useful information.