====== BASH ====== ===== STAZENI A ROZBALENI ONE-LINER ===== $ gzip -d < <(wget -q -O - http://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=gz) > bt_level1 [ https://www.gnu.org/software/bash/manual/bash.html#Process-Substitution ] ===== SERAZENI PODLE VYSKYTU ===== ===== ANALYZA LOGU / MESSAGES ===== $ sudo cut --complement -d' ' -f 1-4 /var/log/messages-20140330| uniq -c -d|sort -g ===== VALIDACE DESKTOP FILES ===== $ find ~/.local/share/applications/ -type f -exec desktop-file-validate {} \; ===== POCET ARG ===== $ echo 0 1 $# ===== VSECHNY ARG ===== ARGS="$@" ===== RETURN LAST STATUS ===== $ $? $ cmd && echo "success" || echo "error" ===== PIPE RETURN STATUS ===== FIGL = ${PIPESTATUS[0]} ./generate-conf.pl -f 01-conf.conf -i -o | while read line; do echo "`date` ${line}" >> generate-conf.log; done if [ "${PIPESTATUS[0]}" == 1 ]; then echo "Generate Error!"; exit; fi echo "Generate successfull" ===== EXIT STATUS ===== $ exit 0-255[int,0=success] ===== KEEP 2 LAST NEW SUBDIRECTORIES ===== find /tmp -maxdepth 1 -mindepth 1 -type d -printf '%T@ %p\n' | sort -nk1| head -n -2| cut -d\\ -f2- NOTE: //maxdepth// and //mindepth// in find /tmp -maxdepth 1 -mindepth 1 ... It's kinda hack to get rid of parent directory [ "/tmp" here ]. NOTE: usage of //head// instead of //tail// head -n -2 this way we keep always 2 in case of less subdirectories.