最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux bash刪除文件中含“指定內(nèi)容”的行功能示例

 更新時(shí)間:2017年06月09日 09:16:21   作者:JoeBlackzqq  
這篇文章主要介紹了Linux bash刪除文件中含“指定內(nèi)容”的行功能,結(jié)合具體實(shí)例形式分析了Linux bash刪除文件指定內(nèi)容的實(shí)現(xiàn)原理與相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Linux bash刪除文件中含“指定內(nèi)容”的行功能。分享給大家供大家參考,具體如下:

#!/bin/sh
# 功能:    刪除文件中含"指定內(nèi)容"的行
# 運(yùn)行方式: ./dline.sh c.log  ==> 產(chǎn)生輸出文件: 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

運(yùn)行情況:

[feng@bash #69]$./dline.sh c.log
556 c.log0
63 c.log0
[feng@bash #70]$

希望本文所述對(duì)大家bash shell學(xué)習(xí)有所幫助。

相關(guān)文章

最新評(píng)論

外汇| 革吉县| 平顺县| 东阳市| 齐齐哈尔市| 定边县| 湖南省| 蒲城县| 建平县| 虞城县| 泸州市| 潞西市| 浦东新区| 罗平县| 红桥区| 类乌齐县| 易门县| 赤峰市| 盱眙县| 睢宁县| 高邑县| 灵寿县| 德兴市| 四平市| 茂名市| 来凤县| 明水县| 樟树市| 饶阳县| 蓝山县| 城口县| 南充市| 丽江市| 师宗县| 兴国县| 涿州市| 思南县| 汶川县| 嵊泗县| 齐齐哈尔市| 盖州市|