Shell
Shell Tricks
- Easy changing directory
cd -
change to last directorypushd
andpops
:pushed
change directory and store the current directory on a stackpops
pop one directory from the stack and change to it
- The environment variable
SHLVL
gives the level of shells I’m in Getting all the href links from a URL
curl -s <url> | grep -o '<a *href *= *"[^"]*"' | cut -d '"' -s -f 2
ls
sort by modification time:ls -t
find
Find broken soft links:
find . -type l | (while read FN ; do test -e "$FN" || ls -ld "$FN"; done)
Find all hard links to some file:
find -x <path> -samefile <file name>
-x
avoids searching in directories with different device numberFind files with modification in the future, use the
-newer
optionfind . -type f -newer <some file>