Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Bash by andre ( 8 years ago )
PATTERN='PR_\S+'
FILES="a.txt b.txt c.txt d.txt"
for file1 in $(echo $FILES); do
  grep -oP $PATTERN $file1 | while read -r match; do
    for file2 in $(echo $FILES); do
      if [ $file1 = $file2 ]; then
        continue
      fi
      echo "testing $match in $file2"
      if grep -q $match $file2; then
        echo "$match in $file2"
        [ ! -f $file1.replaced ] && cp $file1 $file1.replaced
        [ ! -f $file2.replaced ] && cp $file2 $file2.replaced
        sed -i "/$match/d" $file1.replaced
        sed -i "/$match/d" $file2.replaced
      fi
    done
  done
done

 

Revise this Paste

Your Name: Code Language: