标签:
cp
常用选项:
-i:交互式
-r, -R: 递归复制目录及内部的所有内容;
-a: 归档,相当于-dR --preserv=all
-d:--no-dereference[不跟踪符号链接] --preserv=links
--preserv[=ATTR_LIST]
mode: 权限
ownership: 属主属组
timestamp:
links
xattr
context
all
-p: --preserv=mode,ownership,timestamp
-v: --verbose
-f: --force[如果存在覆盖]
mv
常用选项:
-i: 交互式[prompt before overwriting]
-f: 强制 [do not prompt before overwriting]
rm
常用选项:
-i: 交互式
-f: 强制删除
-r: 递归
rm -rf
bash使用特殊变量$?保存最近一条命令的执行状态结果:
0:成功
1-255:失败
[root@localhost mytest3]# pwd
/tmp/mytest3
[root@localhost mytest3]# echo $?
0
[root@localhost mytest3]# pwd1
-bash: pwd1: command not found
[root@localhost mytest3]# echo $?
127
命令行展开
~: 展开为用户的主目录
~USERNAME:展开为指定用户的主目录
{}:可承载一个以逗号分隔的列表,并将其展开为多个路径
/tmp/{a,b} = /tmp/a, /tmp/b
/tmp/{tom,jerry}/hi = /tmp/tom/hi, /tmp/jerry/hi
[root@localhost tmp]# mkdir {a,b}_{c,d}
mylinux/
├── bin
├── boot
│ └── grub
├── dev
├── etc
│ ├── rc.d
│ │ └── init.d
│ └── sysconfig
│ └── network-scripts
├── lib
│ └── modules
├── lib64
├── proc
├── sbin
├── sys
├── tmp
├── usr
│ └── local
│ ├── bin
│ └── sbin
└── var
├── lock
├── log
└── run
[root@localhost tmp]# mkdir -p mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig/network-scripts},lib/modules,lib64,proc,sbin,sys,tmp,usr/local/{bin,sbin},var/{lock,log,run}}
使用stat命令查看
[root@localhost mytest3]# stat ntp.conf
File: `ntp.conf‘
Size: 1923 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 940485 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2013-01-10 07:14:31.000000000 -0800
Modify: 2013-01-10 07:14:31.000000000 -0800
Change: 2016-06-14 05:59:35.931012927 -0700
可使用touch命令修改时间戳信息
使用alias命令
例如:[root@localhost tmp]# alias la=‘ls -la‘
命令引用:
name=`COMMAND`, name=$(COMMAND)
# ls -d /var/l*[0-9]*[[:lower:]]
# ls -d /etc/[0-9]*[^0-9]
# ls -d /etc/[^[:alpha:]][[:alpha:]]*
[root@localhost tmp]# touch tfile-`date +"%Y-%m-%d-%H-%M-%S"`
[root@localhost tmp]# ll|grep tfile-2016-06-14-05-52-37
-rw-r--r--. 1 root root 0 Jun 14 05:52 tfile-2016-06-14-05-52-37
[root@localhost tmp]# cp -a /etc/p*[^0-9] /tmp/mytest1
# cp -a /etc/*.d /tmp/mytest2
[root@localhost tmp]# cp -a /etc/[l,m,n]*.conf /tmp/mytest3
标签:
原文地址:http://www.cnblogs.com/song0156/p/5589341.html