cp -r ./* /Users/jim/new-destination
So the one-liner command I use now to copy Angular projects is this:
cp -r ./. /Users/jim/new-destination
rsync -av --progress ./. ../destination-folder --exclude .git
Writings about one coder's stories & experiences.
Here's a pretty useful little tip for copying a bunch of files at a time.
After scaffolding an Angular project (for example, Gulp-Angular) you'll find yourself looking at a directory filled with normal files and folders as well as hidden files and folders. There are times when I find myself wanting to copy this whole Angular project into another directory. I naively was doing it this WRONG WAY:
cp -r ./* /Users/jim/new-destination
This approach is less than ideal beacause it doesn't copy over all the hidden files and folders (like .bowerrc, .yo-rc.json, .idea, etc.). There are quite a few hidden files and folders so copying them over by hand was pretty annoying. Luckily, the stack overflow user Bruno offered a solution in an answer to this question. Basically, instead of the /* you just can use /. which means, "all files including hidden files". We can then use the -r flag to mean recursive, ie. copy folders as well as files.
So the one-liner command I use now to copy Angular projects is this: cp -r ./. /Users/jim/new-destination
Note: I recently changed up my command slightly because the one above was overwriting the .git file in the destination folder. Not good at all! Unfortunately, the cp command doesn't have an exclude flag. However, this command will copy all files, even hidden ones, but not the .git file:
rsync -av --progress ./. ../destination-folder --exclude .git
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
AuthorThe posts on this site are written and maintained by Jim Lynch. About Jim...
Categories
All
Archives
March 2023
|