cp的常用命令

[root@localhost demo]# cp 1.txt ./aaa/ #复制放入其他文件夹,保留源文件名
[root@localhost demo]# ls aaa/
1.txt
[root@localhost demo]# cp 1.txt ./aaa/2.txt #复制文件放入其他文件夹,且改名
[root@localhost demo]# ls aaa/
1.txt  2.txt
[root@localhost demo]# touch a.txt 
[root@localhost demo]# touch b.txt
[root@localhost demo]# cp a.txt b.txt ./aaa/ #一次性复制多个文件,放入另一个文件夹中
[root@localhost demo]# ls aaa/
1.txt  2.txt  a.txt  b.txt
[root@localhost demo]# cp a.txt ./bbb/
[root@localhost demo]# cp -r bbb aaa  #复制整个文件夹,必须加上-r参数
[root@localhost demo]# ls aaa
1.txt  2.txt  a.txt  bbb  b.txt
[root@localhost demo]# cp -p b.txt d.txt #复制且保持文件属性不变,-p参数用法
[root@localhost demo]# cp a.txt ./aaa
cp: overwrite ‘./aaa/a.txt’? y
[root@localhost demo]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

 

posted @ 2024-12-30 21:01  鲁班大师智商二百五  阅读(21)  评论(0)    收藏  举报