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

首頁(yè) > 系統(tǒng) > Linux > 正文

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

2019-10-26 18:52:58
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

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

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

運(yùn)行情況:

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

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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 惠安县| 三原县| 沁阳市| 南华县| 林甸县| 潼关县| 临澧县| 时尚| 正安县| 安多县| 晋中市| 闸北区| 方城县| 长沙市| 蓝山县| 恩施市| 含山县| 高淳县| 明水县| 和田市| 玉林市| 马鞍山市| 文成县| 皋兰县| 文登市| 安国市| 江津市| 杂多县| 苏尼特右旗| 遵化市| 信宜市| 垫江县| 项城市| 霍邱县| 乌拉特中旗| 当涂县| 峨眉山市| 临海市| 扶沟县| 揭西县| 澄城县|