复制文件
# Copy a file to another location:
$ cp path/to/source_file.ext path/to/target_file.ext
# Copy a file into another directory, keeping the filename:
$ cp path/to/source_file.ext path/to/target_parent_directory
复制文件夹
# Recursively copy a directory's contents to another location (if the destination exists, the directory is copied inside it):
$ cp -R path/to/source_directory path/to/target_directory
# Copy a directory recursively, in verbose mode (shows files as they are copied):
$ cp -vR path/to/source_directory path/to/target_directory
把文件夹递归(-R
)拷贝到另一个文件夹 vs 把文件夹中的子文件(夹)拷贝到另一个文件夹:
# 把文件夹拷贝到另一个文件夹
$ cp -R ./wordpress ./sw_test/
$ playground tree
.
├── sw_test
│ └── wordpress
│ └── docker-compose.yml
└── wordpress
└── docker-compose.yml
3 directories, 2 files
# 把文件夹中的子文件(夹)拷贝到另一个文件夹
# 等价于 cp -vR ./wordpress/* ./sw_test/
$ cp -R ./wordpress/ ./sw_test/
$ tree
.
├── sw_test
│ └── docker-compose.yml
└── wordpress
└── docker-compose.yml
2 directories, 2 files
Reference
FEATURED TAGS
algorithm
algorithmproblem
architecturalpattern
architecture
aws
c#
cachesystem
codis
compile
concurrentcontrol
database
dataformat
datastructure
debug
design
designpattern
distributedsystem
django
docker
domain
engineering
freebsd
git
golang
grafana
hackintosh
hadoop
hardware
hexo
http
hugo
ios
iot
java
javaee
javascript
kafka
kubernetes
linux
linuxcommand
linuxio
lock
macos
markdown
microservices
mysql
nas
network
networkprogramming
nginx
node.js
npm
oop
openwrt
operatingsystem
padavan
performance
programming
prometheus
protobuf
python
redis
router
security
shell
software testing
spring
sql
systemdesign
truenas
ubuntu
vmware
vpn
windows
wmware
wordpress
xml
zookeeper