本文实例讲述了Linux bash删除文件中含“指定内容”的行功能。分享给大家供大家参考,具体如下:
#!/bin/sh
# 功能: 删除文件中含"指定内容"的行
# 运行方式: ./dline.sh c.log ==> 产生输出文件: c.log0
array=(
"rm -f lvr_3531_pf_new"
"arm-hisiv100-linux-gcc "
"In function "
"excess elements in array initializer"
"warning: multi-line comment"
"embedded '\\0' in format"
"__NR_SYSCALL_BASE"
"this is the location of the previous definition"
"dereferencing type-punned pointer will break strict-aliasing rules"
"differ in signedness"
"but argument is of type"
"implicit declaration of"
)
if [ $# -lt 1 ]; then
echo "Usage: $0 <logfile>"
exit
fi
file="$1"0
cp -f $1 $file
function deleteLine()
{
sed "/$1/d" $file > tmp
mv -f tmp $file
}
wc -l $file
for line in "${array[@]}"
do
if [ ${#line} -gt 0 ] && [ ${line:0:1} != "#" ]; then
deleteLine "$line"
fi
done
wc -l $file
运行情况:
[feng@bash #69]$./dline.sh c.log 556 c.log0 63 c.log0 [feng@bash #70]$
希望本文所述对大家bash shell学习有所帮助。
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。