linux基础
cat 段文件
more 长文件
[root@ol85 ~]# head -n 15 anaconda-ks.cfg
[root@ol85 ~]# tail -n 10 anaconda-ks.cfg
[root@ol85 ~]# cat anaconda-ks.cfg | tr [a-z] [A-Z] ====》小写转换成大写,临时
[root@ol85 ~]# wc -l anaconda-ks.cfg ====》统计行数,临时
[root@ol85 ~]# wc -w anaconda-ks.cfg ====》统计单词数
[root@ol85 ~]# wc -c anaconda-ks.cfg ====》统计字节数
atiome 访问时间
mtime : modify 修改时间,内容
ctime : change 更改时间,编辑文件属性时间
grep 按行提取 关键词 文件名
cut 按列提取 参数 文件名
grep oo anaconda-ks.cfg ===》过滤出带有oo的行
grep -n oo anaconda-ks.cfg ===》第几行
grep -v oo anaconda-ks.cfg ===》反选,没有带oo的行
cut -d : -f 1,2 /etc/passwd ===》以 :为间隔符,提取第一列,第二列 文件名
[root@ol85 ~]# cut -d : -f 1,2 /etc/passwd
sort -t : -k 3 -n /etc/passwd
排序
-t : 以:为间隔符,
k 3 提取第三列的信息
-n 以数字的形式
新建文件 touch
touch haha ==新建文本文件,一般文件
[root@192 ~]# mkdir xiaowu ==》新建目录
[root@192 ~]# cd xiaowu
[root@192 xiaowu]# ll
total 0
压缩 tar czvf name.tar.gz 目录/文件
c 打包
z 压缩
v 过程
f 打包后压缩包名称
tar czvf backup.tar.gz /etc
解压tar xvf 压缩包name.tar.gz
z gzip .tar.gz
j bzip 2 tar.bz2
tar xvf backup.tar.gz 解压
输出重定向,清空,覆盖 > 文件中
echo "linux" > 文件
输入重定向,追加 >> 追加重定向
echo "linux" >>文件
echo "linux" 输出到屏幕内容
标准写入 / 错误写入
& 输出
wc 行数
wc -l ana