How to extract first column with a specific character

Hi All,

Below is the sample data of my files:

O|A|571000689|D|S|PNH|S|SI
sadm|ibscml1x|
I|A|571000689|P|S|PNH|S|SI
sadm|ibscml1x|
O|A|571000689|V|S|PNH|S|SI
sadm|ibscml1x|
S|C|CAM|D|S|PNH|R|ZOA|2004
bscml1x|
I|C|CAM|P|S|PNH|R|ZOA|2004
bscml1x|
O|C|CAM|V|S|PNH|R|ZOA|2004
bscml1x|

I need to extract the first column that only contain "I" only?

Please assists

Thanks

sed -n 's/^\(I\).*/\1/p' file

By "extract", do you really mean print only the first column? If not, maybe you mean

grep '^I' file

Dear era,

Thanks. It work.

Actually i'm looking to the first command:

sed -n 's/^\(I\).*/\1/p' file

Can u explain on this?

If the current line matches I at start of line (that's the caret ^), replace the whole line with just the part which matched (that's what the parentheses are for; they capture the match into \1) and print it.