Here is a little trick you should know when selecting directories in a Linux bash script:
Getting a list of directory names in a bash shell is a simple task:
123456789101112131415#!/bin/bash
$MYDIR="/var/log"
DIRS=`ls -l $MYDIR | egrep '^d' | awk '{print $8}'`
# "ls -l $MYDIR" = get a directory listing
# "| egrep '^d'" = [...]
↧