#!/bin/bash sed 's/tyger/(&)/gi' input2.txt > newinput2.txt sed -i 's/&/and/g' newinput2.txt sed -i 's/\ or\ / || /g' newinput2.txt cat newinput2.txt | sed '/^$/d' |sed '1~2p'