Let's say you have a diff: ``` 838a839 > p088x0zn| 841a843 > p088x0zt| 1167a1170 > p088z03m| etc. ``` And you need these pids in format 'p088x0zn', 'p088x0zt', `p088z03m` for a query. This will achieve desired transformation: cat diff.txt | grep -v ">" | grep -v "^[0-9c0-9]" | grep -oE "p[a-z0-9]{7}" | sed "s/.*/'&'/" | paste -sd, -