#!/bin/sh
file="/tmp/3.txt" ab="fff" cc="123" if grep -q "$cc" "$file" then sed -i "/$cc/a $ab" $file sed -i "/$cc/d" $file fi