Linux Snippets

Create a Line Seperator

# function
CL () { WORDS=$@; termwidth="$(tput cols)"; padding="$(printf '%0.1s' ={1..500})"; printf '%*.*s %s %*.*s\n' 0 "$(((termwidth-2-${#WORDS})/2))" "$padding" "$WORDS" 0 "$(((termwidth-1-${#WORDS})/2))" "$padding"; }
# usage
CL test

Source: https://www.commandlinefu.com/commands/view/24626/line-separator-that-is-width-of-terminal

Clone Permissions from one directory to another recursively:

cd /path/to/source
getfacl -R * > /root/source_perm.acl
cd /path/to/destination
setfacl --restore=/root/source_perm.acl

Retrieved from "$'"1"