一、熟练使用查看文件内容的命令
(一)查看文件内容
1、cat -s多个空行合并成一个空行显示 ; -b加行号显示
例如:cat -s test.c
cat -b test.c
2、nl 加行号 例如: nl test.c (相当于cat -b test.c)
3、head -n文件名(前n行,默认10) 例如: head -2 tail -5
4、tail -n文件名(后n行,默认10)
二、熟练使用文件复制命令
(一)复制
1、cp [options] file destination
常用选项: i:覆盖时交互提示
r:对文件夹递归
2、复制多个文件到文件夹:;cp [options] file1 file2 dest
例如:cp test.c test4.c
cp test.c …/
cp test.c /home/linux
cp test.c …/bak.c
cp -r testsubdir/ bakdir
cp test.c …/ -I
三、熟练使用文件移动命令
(一)移动
1、mv:mv[options] file destination
(1)移动多个文件:
mv [options] file1 file2 destination
(2)更改文件名:
例如:mv test.c …/
mv test2.c test_second.c 重命名
mv test3.c test_three.c 移动加重命名
四、熟练使用创建和删除文件命令
(一)创建和删除
1、touch -创建文件或更新时间戳
2、rm -删除文件
rm -i 删普通文件
rm -r 删文件夹
例如:touch a.c 创建文件 如果已经存在就更改时间(修改时间)
rm -I test3.c 删除文件
rm -r bakdir 删除文件夹
3、mkdir:新建文件夹
例如:mkdir -p是级联创建
rm -r删除文件夹
mkdir -p d2/d22