cat test4 |awk'{
for (i=1; i<=NF; i++) { %遍历文件每列
if (NR==1) { %第一行
res[i]=$i; %保存到数组,数组保存转置后的行
}
else { %非第一行
res[i]=res[i] " " $i %修改数组值,追加当前字符
}
}
}
END {
for (i=1; i<=NF; i++) { %结束,遍历列,(行列数相同)
print res[i] %逐行打印
}
}'
去掉文件中含有特定单词的语句并将剩余输出
题目描述
写一个 bash脚本以实现一个需求,去掉输入中含有this的语句,把不含this的语句输出
示例:
假设输入如下:
that is your bag
is this your bag?
to the degree or extent indicated.
there was a court case resulting from this incident
welcome to nowcoder
你的脚本获取以上输入应当输出:
to the degree or extent indicated.
welcome to nowcoder