1.cp (Copy files)
cp -i 源文件 目的文件 -i(提示)
cp -r dir3 dir4 -r(目录)
2.mv (Move or rename files and directories)
3.rm & rmdir只能删除空目录
4.Metacharacters(元字符)扩展现有命令功能
Examples: ; $ <> ! ~ * ? [] |
5.*(Represents zero or more characters)
ls d*展示以d开头的
?(Represents any single character)
ls d?? 表示以d开头的俩个字符
[](Match a set or range of characters to a single character position)
(匹配[]中的一个字符)
;(Enter multiple commands on a command line)在命令行上输入多个命令
date输出当前日期
cal 输出日历
>重定向标准输出
cal 1900 >t.txt将1990年的日历输出到t.txt
date >>t.txt将当前日期继续输出到t.txt
<重定向标准输入
|(Takes the output of one command and passes it as input into a following command)将上一个命令的输出作为下一个命令的输入
cal 7 2003 | lp将2003年7月的数据输出到打印机上
ps -aux展示所有的进程
6.cat /dev/null > ~/b.txt清空b.txt的数据
cat /etc/passwd | awk -F: '{print $1 "\t" $5}' \
| sort > ~/userinfo
awk逐行操作
-F:以:作为分割字符
\续航操作符
7.vi
:set nu设置行号
vi filename (open or create a file)
input:
i 在光标位置前插入
a 在光标位置后插入
o 在光标所在行下插入一空行
Esc 退出插入状态
Deleting text
x 删除一个字符
dw 删除当前词
3dw 删除三个词
dd 删除当前行
5dd 删除5行
:5,10d 删除5-10行(底层操作模式) $最后一行
Change Text:
r 替换一个字符
cw 替换一个单词
cc 替换一行
C 替换光标至行尾
Copying and Pasting Text
yw 拷贝词
yy 拷贝行或y
p 当前行下粘贴
:1,2co3 拷贝行1,行2在行3之后
:4,5m6 移动行4,行5在行6之后
Saving and Quiting files
:w 存盘
:w newfile 存成新的文件
:wq 存盘退出vi(或ZZ,或:x)
:q! 强行退出不存盘
Advanced Editing Options (高级编辑选项)
~ 改变大小写
J 把当前行与下一行连接起来
u 废除刚才的编辑操作(undo)
:set nu 显示行代码(:set nonu)
:21 光标停在指定行
21G 光标停在指定行(G到文件尾,1G到文件头)
/串 从当前行往下查找
?串 从当前行往上查找
n 继续查找
:r file2 在光标所在位置插入另一个文件
:1,$s/旧串/新串/g 替换全文(或:$s/旧串/新串/g)
压缩
gzip filename 压缩效率依次降低gzip最小,速度最慢
bzip2 filename
zip filename.zip filename(s)
eg: gzip file1
减压:
gunzip
bunzip2
unzip
打包:
pack
-c建立一个档案的参数
unpack
diff:用来比对俩个文件是否一样
cp -i 源文件 目的文件 -i(提示)
cp -r dir3 dir4 -r(目录)
2.mv (Move or rename files and directories)
3.rm & rmdir只能删除空目录
4.Metacharacters(元字符)扩展现有命令功能
Examples: ; $ <> ! ~ * ? [] |
5.*(Represents zero or more characters)
ls d*展示以d开头的
?(Represents any single character)
ls d?? 表示以d开头的俩个字符
[](Match a set or range of characters to a single character position)
(匹配[]中的一个字符)
;(Enter multiple commands on a command line)在命令行上输入多个命令
date输出当前日期
cal 输出日历
>重定向标准输出
cal 1900 >t.txt将1990年的日历输出到t.txt
date >>t.txt将当前日期继续输出到t.txt
<重定向标准输入
|(Takes the output of one command and passes it as input into a following command)将上一个命令的输出作为下一个命令的输入
cal 7 2003 | lp将2003年7月的数据输出到打印机上
ps -aux展示所有的进程
6.cat /dev/null > ~/b.txt清空b.txt的数据
cat /etc/passwd | awk -F: '{print $1 "\t" $5}' \
| sort > ~/userinfo
awk逐行操作
-F:以:作为分割字符
\续航操作符
7.vi
:set nu设置行号
vi filename (open or create a file)
input:
i 在光标位置前插入
a 在光标位置后插入
o 在光标所在行下插入一空行
Esc 退出插入状态
Deleting text
x 删除一个字符
dw 删除当前词
3dw 删除三个词
dd 删除当前行
5dd 删除5行
:5,10d 删除5-10行(底层操作模式) $最后一行
Change Text:
r 替换一个字符
cw 替换一个单词
cc 替换一行
C 替换光标至行尾
Copying and Pasting Text
yw 拷贝词
yy 拷贝行或y
p 当前行下粘贴
:1,2co3 拷贝行1,行2在行3之后
:4,5m6 移动行4,行5在行6之后
Saving and Quiting files
:w 存盘
:w newfile 存成新的文件
:wq 存盘退出vi(或ZZ,或:x)
:q! 强行退出不存盘
Advanced Editing Options (高级编辑选项)
~ 改变大小写
J 把当前行与下一行连接起来
u 废除刚才的编辑操作(undo)
:set nu 显示行代码(:set nonu)
:21 光标停在指定行
21G 光标停在指定行(G到文件尾,1G到文件头)
/串 从当前行往下查找
?串 从当前行往上查找
n 继续查找
:r file2 在光标所在位置插入另一个文件
:1,$s/旧串/新串/g 替换全文(或:$s/旧串/新串/g)
压缩
gzip filename 压缩效率依次降低gzip最小,速度最慢
bzip2 filename
zip filename.zip filename(s)
eg: gzip file1
减压:
gunzip
bunzip2
unzip
打包:
pack
-c建立一个档案的参数
unpack
diff:用来比对俩个文件是否一样