i have text file mentioned below, , along pass input want corresponding output.
input file: test.txt
abc:abc_1 abcd:abcd_1 1_abcd:1_abcd_bkp xyz:xyz_2 so if use abc above test.txt file, want abc_1; , if pass abcd, need abcd_1 output.
i tried cat text.txt | grep abc | cut -d":" -f2,2, getting output
abc_1 abcd_1 1_abcd_bkp when want abc_1.
with gnu grep:
grep -po "^abc:\k.*" file output:
abc_1
\kkeeps text matched far out of overall regex match.
Comments
Post a Comment