Got GNU?
The gnu version of ls
has --group-directories-first
. And cp
has -t
.
No GNU?
On systems that don’t have gnu’s ls
, your best bet is two successive calls to find
with -maxdepth n
/-mindepth n
and -type t
with the appropriate options.
find . -maxdepth 1 -mindepth 1 -type d
find . -maxdepth 1 -mindepth 1 \! -type d
For copying files, with the target first, you would have to write a script that saves the first argument, then uses shift
, and appends the argument to the end.
#!/bin/sh
target="$1"
shift
cp -r -- "$@" "$target"