C
cibalo
Hello,
I would like to try some string matching in perl as is in the title.
Let's create some testfiles for testing as follows.
$ mkdir -vp testing/dir.a/dir_b/dir-c; cd testing/dir.a/dir_b/dir-c; \
touch This_is_testing1_org.txt This-is-testing2_org.txt \
this_is_testing3_org.txt this-is-testing4_org.txt; cd
What I am looking for is the result similar to:
$ find testing -type f -name "[a-z]*\.txt"
testing/dir.a/dir_b/dir-c/this-is-testing4_org.txt
testing/dir.a/dir_b/dir-c/this_is_testing3_org.txt
I know it is more easier to find the result this way.
Now I try with perl regex as:
$ ls testing/dir.a/dir_b/dir-c/* | perl -ne '/^(.*\/)([a-z].*)$/;
print $1, " - ", $2, "\n";'
testing/dir.a/dir_b/ - dir-c/This_is_testing1_org.txt
testing/dir.a/dir_b/ - dir-c/This-is-testing2_org.txt
testing/dir.a/dir_b/dir-c/ - this_is_testing3_org.txt
testing/dir.a/dir_b/dir-c/ - this-is-testing4_org.txt
Actually, I want my leftmost greedy quantifier, (.*\/), to be so
greedier that it can prevent the first two output items from listing.
What interests me most is this:
$ ls testing/dir.a/dir_b/dir-c/* | perl -ne '/^(.*\/)([A-Z].*)$/;
print $1, " - ", $2, "\n";'
testing/dir.a/dir_b/dir-c/ - This_is_testing1_org.txt
testing/dir.a/dir_b/dir-c/ - This-is-testing2_org.txt
testing/dir.a/dir_b/dir-c/ - This-is-testing2_org.txt
testing/dir.a/dir_b/dir-c/ - This-is-testing2_org.txt
"This-is-testing2_org.txt" is repeated three times.
Can you please let me know what I'm missing?
Thank you very much in advance!!!
Best Regards,
cibalo
I would like to try some string matching in perl as is in the title.
Let's create some testfiles for testing as follows.
$ mkdir -vp testing/dir.a/dir_b/dir-c; cd testing/dir.a/dir_b/dir-c; \
touch This_is_testing1_org.txt This-is-testing2_org.txt \
this_is_testing3_org.txt this-is-testing4_org.txt; cd
What I am looking for is the result similar to:
$ find testing -type f -name "[a-z]*\.txt"
testing/dir.a/dir_b/dir-c/this-is-testing4_org.txt
testing/dir.a/dir_b/dir-c/this_is_testing3_org.txt
I know it is more easier to find the result this way.
Now I try with perl regex as:
$ ls testing/dir.a/dir_b/dir-c/* | perl -ne '/^(.*\/)([a-z].*)$/;
print $1, " - ", $2, "\n";'
testing/dir.a/dir_b/ - dir-c/This_is_testing1_org.txt
testing/dir.a/dir_b/ - dir-c/This-is-testing2_org.txt
testing/dir.a/dir_b/dir-c/ - this_is_testing3_org.txt
testing/dir.a/dir_b/dir-c/ - this-is-testing4_org.txt
Actually, I want my leftmost greedy quantifier, (.*\/), to be so
greedier that it can prevent the first two output items from listing.
What interests me most is this:
$ ls testing/dir.a/dir_b/dir-c/* | perl -ne '/^(.*\/)([A-Z].*)$/;
print $1, " - ", $2, "\n";'
testing/dir.a/dir_b/dir-c/ - This_is_testing1_org.txt
testing/dir.a/dir_b/dir-c/ - This-is-testing2_org.txt
testing/dir.a/dir_b/dir-c/ - This-is-testing2_org.txt
testing/dir.a/dir_b/dir-c/ - This-is-testing2_org.txt
"This-is-testing2_org.txt" is repeated three times.
Can you please let me know what I'm missing?
Thank you very much in advance!!!
Best Regards,
cibalo