First, the demand
Here, I simplify, because this afternoon operation both texts are 10 tens of thousands of lines, but only filter out these two files contain the same or different string ppid.
Two, step together
1. Document HA1
Abc
2. Document HA2
Acd
3. Find out that two files contain a string ppid
3.1 Filtering scripts
#!/bin/sh#set-xsrc_file=$1target_file=$2result_file=$3> $RESULT _filewhile Read linedogrep $LINE $TARGET _file > /dev/nullif [$?-eq 0]; Thenecho $LINE >> $RESULT _filefidone < $SRC _file#set +x
3.2 Execution Results
[Email protected]]#./filter.sh ha1 ha2 ha3[[email protected]] #cat HA3AC
4. Find out if one of the files does not pack a string ppid
4.1 Modify $? Not equal to 0.
#!/bin/sh#set-xsrc_file=$1target_file=$2result_file=$3> $RESULT _filewhile Read linedogrep $LINE $TARGET _file > /dev/nullif [$?-ne 0]; Thenecho $LINE >> $RESULT _filefidone < $SRC _file#set +x
4.2 Execution Results
[Email protected]]#./filter.sh ha1 ha2 ha3[[email protected]] #cat ha3b
This article is from the "Scattered People" blog, please be sure to keep this source http://zouqingyun.blog.51cto.com/782246/1750069
Find two files containing strings or strings that are not included in shell scripts