Sunday, November 12, 2017

Replace a list of patterns with another list


$ while IFS= read -r aline; do filename=`echo "$aline" \| 
cut -f1 -d "        " `; phyloID=`echo "$aline" \| 
cut -f2 -d "  " `; 
sed -i "s/$filename/$phyloID/"  file_with_pattern_to_be_replaced.txt ; 
echo "$aline";  done < id_values.txt


## "id_values.txt" - contains pattern and replacement, separated by tab

## "file_with_pattern_to_be_replaced.txt" - replace patterns in this file

No comments:

Post a Comment