-- input file is ----- "aaa" || "bbb" this is if ( "ccc" && "ddd" junk ------- desired output is --------- aaa bbb ccc ddd ------------- script file is ----------------- s/||/\n/g s/&&/\n/g s/"/&/g s/.*"\(.*\)".*/\1/p ----------- result is ------------------ sed -nf scr1 fu bbb ddd