本文介绍: cat file | awk ‘{print substr($1,1,5)}’ 分别是第1个字段,第1个字符到第5个字符sed “/$x/d/” filesedn “$ip file整数比较if [ “$a” –eq “$b” ] a,b整数。按列: paste a b > c文件a b 以列的形式合并字符串比较if [ “$a” = “$b” ] a,b字符串。:echo -n ” ” >> temp (不换行)按行:cat a>>b文件a追加文件b的尾部。

指定shell脚本解释器路径,只能放在文件第一行

输出空行: echo ” ” >> temp自动换行
输出空格:echo -n ” ” >> temp (不换行

按列: paste a b > c 将文件a b 以列的形式合并
按行:cat a>>b 将文件a追加到文件b的尾部

cat -n file | grepkeywords

num=`cat file | grep -n ‘kewords‘| awk -F”:” ‘{print $1}’`
ps:第一对键盘左上角的点号

if [ –f $content ]

cat $content | sed -n “$num,$(($num+10))p”

sed “/$x/d/” filesed -n “$i”p file

整数比较: if [ “$a” -eq “$b” ] a,b为整数
字符串比较:if [ “$a” = “$b” ] a,b为字符串

cat file | awk ‘{print $0}’ print换行
cat file | awk ‘{printf $0}’ printf不换行

echo $’n’ >>file

awk -F”:” ‘{$1=”Demo:”;print $0}’ file

awk -F”:” -f script file
script内容
{
$1=“Demo:”
print $0
}

cat file | awk ‘{print substr($1,1,5)}’ 分别是第1个字段,第1个字符到第5个字符

awk -F” ” ‘{print $”‘$i'”}’

cat file | awk -F” ” ‘{for(i=1;i<=NF;i++) print $i}’

原文地址:https://blog.csdn.net/qq_35902025/article/details/127173429

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_45802.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注