find
is an incredibly powerful command, but I can't ever remember how to use it.
I realized that off the top of my head I didn't know the answer to your question, but thought that file globs might be useful, so here's what I tried:
/tmp/askubuntu $ ls # notice no output because this directory is currently empty
/tmp/askubuntu $ mkdir src dest # create source and desination directories
/tmp/askubuntu $ ls # now we have the two directories we created
dest src
/tmp/askubuntu $ cd src
/tmp/askubuntu/src $ ls # no files in src, yet
/tmp/askubuntu/src $ touch file-1 file-2 # create a couple of empty files
/tmp/askubuntu/src $ ls # now we can see the files that we created
file-1 file-2
/tmp/askubuntu/src $ mkdir dir-to-ignore # make a directory that we don't want to copy
/tmp/askubuntu/src $ ls -l # we can use 'ls -l' to view the files as well as their types. note the 'd' to the left of dir-to-ignore -- this says it is a directory
total 4
drwxr-xr-x 2 josh josh 4096 Oct 24 00:06 dir-to-ignore
-rw-r--r-- 1 josh josh 0 Oct 24 00:05 file-1
-rw-r--r-- 1 josh josh 0 Oct 24 00:05 file-2
/tmp/askubuntu/src $ cd ../dest/
/tmp/askubuntu/dest $ ls
/tmp/askubuntu/dest $ touch file-3 # make an empty file here too
/tmp/askubuntu/dest $ cd ../src/
/tmp/askubuntu/src $ ls
dir-to-ignore file-1 file-2
/tmp/askubuntu/src $ cp * ../dest/ # copy all files from our current directory (* matches anything) to ../dest
cp: omitting directory ‘dir-to-ignore’
/tmp/askubuntu/src $ ls # our current directory is unchanged
dir-to-ignore file-1 file-2
/tmp/askubuntu/src $ cd ../dest/
/tmp/askubuntu/dest $ ls # but we copied all of files we wanted, and nothing more
file-1 file-2 file-3
The reason for this works isn't immediately obvious. Had we given cp
the -r
flag (so cp -r * ../dest/
), we would have also copied over dir-to-ignore
in addition to all of its contents. This is because -r
indicates to copy directories recursively (as we can see by typing man cp
at a terminal). So in your case this might become cp -a /home/troy/Downloads/* /home/troy/.gs/
. Or you can omit the -a
if you desire.
I don't claim that relying on this slightly odd behavior of cp (not copying directories without the -r
flag, but also not giving an error) is the right thing to do. My goal was to illustrate how I might try to construct a solution to this problem and illustrate a few commands along the way.
Maybe you'll find it useful, maybe you won't, maybe you already know all of this. Just my two cents. But regardless, I think it's nice to know how/why things work and be able to explore solutions on your own.