欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > > 文章正文

Read write text file in shell,writetext

来源: javaer 分享于  点击 6708 次 点评:119

Read write text file in shell,writetext


#!/bin/bash
contains() {
    string="$1"
    substring="$2"
    if test "${string#*$substring}" != "$string"
    then
        return 0    # $substring is in $string
    else
        return 1    # $substring is not in $string
    fi
}


file=$1
dest=$2
rm $dest
while IFS= read -r line
do
        # display $line or do somthing with $line
        echo "$line" >> "$dest"


        contains "$line" ",ABC," && echo $line | sed -e "s/,ABC,/,ZRM,/g" >> "$dest"
       
done <"$file"

 

相关文章

    暂无相关文章

用户点评