本文介绍: 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}’

发表回复

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