Tuesday, April 10, 2018

Linux stuff

Change bash prompt

https://wiki.centos.org/TipsAndTricks/CustomizeBash
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
https://superuser.com/questions/60555/show-only-current-directory-name-not-full-path-on-bash-prompt



bash newline:

printf "hi \n there \n"

echo $'hi \nthere'
Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard.


Check if directory exists (or not)
https://stackoverflow.com/questions/59838/check-if-a-directory-exists-in-a-shell-script


if [ ! -d "$DIRECTORY" ]; then
  # Control will enter here if $DIRECTORY doesn't exist.
fi

If symbolic links are present:

if [ -d "$LINK_OR_DIR" ]; then 
  if [ -L "$LINK_OR_DIR" ]; then
    # It is a symlink!
    # Symbolic link specific commands go here.
    rm "$LINK_OR_DIR"
  else
    # It's a directory!
    # Directory command goes here.
    rmdir "$LINK_OR_DIR"
  fi
fi



No comments:

Post a Comment