Sam Hakim Sam Hakim - 7 months ago 24
Bash Question

Match pattern in line using grep

I need to grep lines from a file with comma separated values, and direct the output to another file. Thus, if the second value starts with 'U' and the last value is 'Success', then this line matches the pattern.

Should match the pattern:


Should fail to match:


Thank you!

grep '^[^,]*,U.*,Success$'

Look for the first comma, a U, the last comma, Success and end of line.