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

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

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

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

#!/bin/sh
# 功能:    刪除文件中含"指定內(nèi)容"的行
# 運行方式: ./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

運行情況:

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

希望本文所述對大家bash shell學習有所幫助。

相關(guān)文章

最新評論

瓦房店市| 静乐县| 淅川县| 即墨市| 巴彦淖尔市| 蓬安县| 海宁市| 米脂县| 金湖县| 大城县| 丰镇市| 景宁| 威宁| 桂林市| 来安县| 云霄县| 根河市| 康保县| 遵义县| 曲松县| 丹东市| 霞浦县| 庄河市| 南汇区| 安达市| 西乡县| 浦北县| 蒙山县| 铁岭县| 汤原县| 沙河市| 噶尔县| 黄大仙区| 尤溪县| 张家川| 鸡西市| 合川市| 即墨市| 宁城县| 和平县| 固始县|