Read write text file in shell

#!/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
    be
}


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"

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326524804&siteId=291194637