.bash文件标记 #!/bin/bash
2.2.. 参数1 参数2..
$0 文件名
$? 程序或命令执行的返回值
$# 参数个数
$* 参数列表
3.打印日期 ·Date +%Y%m%d· 反引号
4.打印加颜色echo -e "\033[32m -------\033[0m"
5.if -f filename
if [[ -gt 80 ]]比较大小需要两个中括号
6.sh -n name.sh 检查脚本是否有错误
- for i in
do
done
8.until ;
do
done
9.sed 修改文件内容
awk 打印
find . -maxdepth 1 -type f -name ".txt" -exec cp {} temp/ ;
-size +50M
| xargs
10.tar -g
一.
!打印不放入双引号或加转义
echo/printf - 终端打印
echo -e "" 包含转义
彩色打印:
文字颜色- 重置0 黑色30 红色31 绿色32 黄色33 蓝色34 洋红35 青色36 白色37
背景颜色- 重置0 黑色40 红色41 绿色42 黄色43 蓝色44 洋红45 青色46 白色47
echo -e "\e[1;31m red text \e[0m"
> 定向保存 >>追加
tee - 打印同时定向文件
!否定参数 find . ! -name "*.txt" -print
find 深度选项 -maxdepth -mindepth
-type可以对文件搜索进行过滤
根据时间 -atime 访问时间 -mtime修改时间 -ctime文件元数据
find . -type f -atime [+-]7 -print
-size [+-]2k 文件大小
-delete 删除
利用find执行命令 find . -type f -name "*.c" -exec cat {} ;
xargs 有些命令只能以命令行参数的形式接受数据
echo "splitXsplitXsplitXsplit" | xargs -d X -n 2 -n划分多行
tr 进行字符替换 删除 重复字符压缩。
tr -d
tr -c 补集
tr -s
校验 md5sum
加密工具与散列
排序去重 sort uniq
三.
1.生成文件
dd if=/dev/zero of=junk.daa bs=1M count=1
if输入文件 of输出文件 bs以字节为单位i=的块大小 count需要被复制的块数
/dev/zero 字符设备 不断返回0值字节 \0
2.文本文件的交集和差集
comm 用于两个文件的比较 必须使用排过序的文件作为输入
sort a.txt -o a.txt
wc -l行数 -w单词数 -c字符数