Print the absolute path of a file with realpath
TIL: use realpath to print the absolute path of a file. Useful for creating symlinks. for f in $(realpath scripts/linux/*); do ln -s "$f" ~/bin/$(basename "$f"); done
TIL: use realpath to print the absolute path of a file. Useful for creating symlinks. for f in $(realpath scripts/linux/*); do ln -s "$f" ~/bin/$(basename "$f"); done
Used shellcheck, a shell linter, very useful.
TIL: pipe output of commands that are tabular to the column command to make them more readable
TIL: use the readlink command to resolve symbolic links to executables. Use the -f option to follow the link recursively. # find the path to the youtube-dl script. readlink -f $(which yt-dlp)
https://stackoverflow.com/questions/3224878/what-is-the-purpose-of-the-colon-gnu-bash-builtin https://unix.stackexchange.com/questions/31673/what-purpose-does-the-colon-builtin-serve Historically, Bourne shells didn’t have true or false as built-i commands. true was simply aliased to : : is slightly better than true for portability. Uses: # alias to true while : ; do command ; done # variable expansion, assign default value var= : ${var:=DEFAULT} echo $var DEFAULT
Last monday I learned that $_ in a script expands to the last argument of the previous command
TIL: to regexp match a string and use it as a condition, pipe it to grep -Eq $ protoc --version | cut -d' ' -f2 | grep -Eq ${PROTOC_VERSION} || { echo 'Incompatible protoc version'; exit 1; }