What is the difference among following path patterns in Linux
./e.g.cp ./ [destination-path]./.e.g.cp ./. [destination-path]./*e.g.cp ./* [destination-path]./**e.g.cp ./** [destination-path]
The first two would make more sense with a recursive copy, i.e. cp -r. The difference comes up if the source is a named directory, and the destination exists. Of these:
cp -r src/ dest
cp -r src/. dest
the first would copy src into dest, creating dest/src and files within it (src/a becomes dest/src/a), while the latter copies the contents of src, so src/a becomes dest/a.
In the other two, the shell expands the glob, so the contents of the directory (except dotfiles) are copied even without -r.
cp ./* dest
cp ./** dest
In the first, the shell expands ./* to the list of filenames in the current directory (except those starting with a dot), and cp copies them. In the second, shells supporting it would expand ./** to a recursive listing of filenames, and again cp would copy the files it was listed.
The recursive ** works at least in Bash if shopt -s globstar is set, in ksh with set -o globstar.
Neither Bash or ksh includes files or directories with names starting with dot in the result of **, regardless of which level in the tree they appear, so using that is not a very good way to make a complete copy of a full directory structure; cp -r . dest would copy dotfiles too.
Bash has shopt -s dotglob which unhides dotfiles with both * and **, I'm not sure if ksh has a similar feature.
cp ./** dest/ would miss all dotfiles, unless you use shopt -s dotglob in Bash. So it's probably easier to just use cp -r for recursive copies (or cp -a in GNU cp).
cpas an example to make my question clear. I want to know the main difference.