Z
Z
Zueuk2017-02-01 18:27:14
bash
Zueuk, 2017-02-01 18:27:14

How to filter list of paths by pattern by regex in bash script?

There is a list of paths:
./path/20170116090256_WRP_A01.0242
./path/WRP_G01_006563
./path/WRP_G01_006563/sql/apps/pkgs
Compiled regular expression [AZ]{3}\_*$ , according to which the list is filtered. The following lines fall under this filter:
./path/20170116090256_ WRP_A01.0242
./path/ WRP_G01_006563
./path/ WRP_G01_006563 /sql/apps/pkgs
of the two (maybe more)
./path/ WRP_G01_006563
./path/ WRP_G01_006563/sql/apps/pkgs
./path/ WRP_G01_006563/another/path
leave only
./path/WRP_G01_006563
Tell me what is wrong in the regular expression and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2017-02-01
@Zueuk

grep -P [A-Z]{3}\_[^/]*$ file.lst

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question