国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Linux Shell > 正文

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

2020-07-27 18:53:53
字體:
來源:轉載
供稿:網友

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

#!/bin/sh# 功能:    刪除文件中含"指定內容"的行# 運行方式: ./dline.sh c.log  ==> 產生輸出文件: c.log0array=(  "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>"  exitfifile="$1"0cp -f $1 $filefunction deleteLine(){  sed "/$1/d" $file > tmp  mv -f tmp $file}wc -l $filefor line in "${array[@]}"do  if [ ${#line} -gt 0 ] && [ ${line:0:1} != "#" ]; then    deleteLine "$line"  fidonewc -l $file

運行情況:

[feng@bash #69]$./dline.sh c.log556 c.log063 c.log0[feng@bash #70]$

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 绿春县| 扶风县| 宁津县| 宁德市| 佳木斯市| 灌云县| 图片| 孟州市| 阜城县| 南康市| 汶川县| 云林县| 庆城县| 武功县| 新余市| 镇安县| 荥阳市| 瓦房店市| 宁陕县| 沂南县| 镇宁| 武穴市| 浦县| 阿拉善右旗| 肥东县| 灵璧县| 遂昌县| 垣曲县| 汽车| 滦南县| 元阳县| 正蓝旗| 托里县| 洞口县| 闽清县| 德惠市| 漳浦县| 吴江市| 泰来县| 平谷区| 黔南|