I have the following type of output from a find and grep pipe./Columbia/815425_0001104659-11-049107.txt:         CENTRAL INDEX KEY:              0000815425./Columbia/815425_0001104659-12-060231.txt:         CENTRAL INDEX KEY:              0000815425./Columbia/815425_0001104659-13-066298.txt:         CENTRAL INDEX KEY:              0000815425./Dimensional Advisors/355437_0001137439-04-000108.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-05-000205.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-06-000306.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-08-000364.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-09-000076.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-12-000295.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001140361-10-035592.txt:         CENTRAL INDEX KEY:              0000355437I would like to obtainColumbia 0000815425Columbia 0000815425Columbia 0000815425Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437I was thinking sed and grep, but I am stuck with how to combine everything: matching the first part: (how do I match just before the /?)erik Funds$ cat myoutput | egrep -o [A-Z].*/Columbia/Columbia/Columbia/Dimensional Advisors/Dimensional Advisors/Dimensional Advisors/Dimensional Advisors/Dimensional Advisors/Dimensional Advisors/Dimensional Advisors/and the last 10 digit numbers:erik Funds$ cat myoutput | egrep -o [0-9]{10}$0000815425000081542500008154250000355437000035543700003554370000355437000035543700003554370000355437
Match first part of pathname and number at end of line
bash;sed;grep
awk with / as field separator, and then printing field 2 and field 3 (with necessary zero padding):... | awk -F/ '{ printf(%s %010d\n, $2, $3) }'Example:$ cat file.txt ./Columbia/815425_0001104659-11-049107.txt:         CENTRAL INDEX KEY:              0000815425./Columbia/815425_0001104659-12-060231.txt:         CENTRAL INDEX KEY:              0000815425./Columbia/815425_0001104659-13-066298.txt:         CENTRAL INDEX KEY:              0000815425./Dimensional Advisors/355437_0001137439-04-000108.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-05-000205.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-06-000306.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-08-000364.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-09-000076.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001137439-12-000295.txt:         CENTRAL INDEX KEY:              0000355437./Dimensional Advisors/355437_0001140361-10-035592.txt:         CENTRAL INDEX KEY:              0000355437$ awk -F/ '{ printf(%s %010d\n, $2, $3) }' file.txtColumbia 0000815425Columbia 0000815425Columbia 0000815425Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437Dimensional Advisors 0000355437