September 2018
Beginner
186 pages
4h 30m
English
We could adapt our preceding mkcd function to a new function, mkls, that creates directories and then prints them with ls -dl. The -d option to ls lists the directory itself, rather than its content. This implementation works well:
bash$ mkls() { mkdir -- "$1" && ls -dl -- "$1" ; }
bash$ mkls newdir
drwxr-xr-x 2 bashuser bashuser 4 2018-07-17 20:30:33 newdir/
However, this approach only allows us to create one directory. Because both mkdir and ls accept more than one directory name, we could create two of them like this:
bash$ mkls2() { mkdir -- "$1" "$2" && ls -dl -- "$1" "$2" ; }
bash$ mkls2 newdir1 newdir2
drwxr-xr-x 2 tom tom 4 2018-07-17 20:32:03 newdir1/
drwxr-xr-x 2 tom tom 4 2018-07-17 20:32:03 newdir2/Read now
Unlock full access