查找1.txt中出现2.txt里的文字的结果输出到final.txt
awk 'NR==FNR{a[$1];next}{s=substr($0,5);if((s in a)){print substr($0,1,11)}}' 1.txt 2.txt>final.txt
取两个文件的交集
grep -F -f a.txt b.txt | sort | uniq
删除一周前的文件
find /home/log -mtime +7 -name "*.log" -exec rm -rf {} \;
替换不可见字符SOH,两种方法:
1:sed -i 's/^A/|/g' test.txt > test2.txt //其中^A 是通过 Ctrl+V+A 打出来的
2:tr '\001' '\|' test2.txt
过滤文件,以:分隔,取冒号后面的值
cat test.txt |awk -F ':' '{print $2}' > test2.txt
替换文本中的字符串
sed -i 's/原字符串/替换字符串/g' test.txt
文件每行行首添加指定字符
sed -i 's/^/&添加的字符串/' test.txt
文件每行行尾添加指定字符
sed -i 's/$/&添加的字符串/' test.txt
切割文件
split -b 100m test.log (按照字节分隔)
split -l 1000000 test.log(按照行数分隔)
curl post提交
curl -l -H "Content-type: application/json" -X POST -d 'jsonStr=xxxxx‘ http://localhost:8080/api/postxx
md5加密
echo -n 'hello'|md5sum|cut -d ' ' -f1
awk 'NR==FNR{a[$1];next}{s=substr($0,5);if((s in a)){print substr($0,1,11)}}' 1.txt 2.txt>final.txt
取两个文件的交集
grep -F -f a.txt b.txt | sort | uniq
删除一周前的文件
find /home/log -mtime +7 -name "*.log" -exec rm -rf {} \;
替换不可见字符SOH,两种方法:
1:sed -i 's/^A/|/g' test.txt > test2.txt //其中^A 是通过 Ctrl+V+A 打出来的
2:tr '\001' '\|' test2.txt
过滤文件,以:分隔,取冒号后面的值
cat test.txt |awk -F ':' '{print $2}' > test2.txt
替换文本中的字符串
sed -i 's/原字符串/替换字符串/g' test.txt
文件每行行首添加指定字符
sed -i 's/^/&添加的字符串/' test.txt
文件每行行尾添加指定字符
sed -i 's/$/&添加的字符串/' test.txt
切割文件
split -b 100m test.log (按照字节分隔)
split -l 1000000 test.log(按照行数分隔)
curl post提交
curl -l -H "Content-type: application/json" -X POST -d 'jsonStr=xxxxx‘ http://localhost:8080/api/postxx
md5加密
echo -n 'hello'|md5sum|cut -d ' ' -f1