Regular expression for file and directory listing
I guess ls is a laudable command in the Linux world – the fact that everything is a file, we exploit it in a daily manner.
One usage of the a helpful command on ls is grep for listing regex’d listing.
here is the the simplest command that can list all the files/directories with that start with ‘pe’
First we would be on the directory we want the listing, then we would pipe the listing to grep!
ls | grep "^pe.*"
Even
ls | grep "^pe"
would result the same.
One that contains pe would be
ls | grep "pe"
and the one that ends with pe would be
ls | grep "pe$"
Further reading Ubunutu help on grep
See how you would solve these known algorithm problems
Array reversal in Recurrsionbinary tree problems with solution
Changing decimal number to its binary equivalent
Find longest palindrom from sequence of characters
String Ordered Permutation Algorithm Problem
testing k complementary pairs algorithm with junit
Find the pairs that makes K Complementary in the given array java solution
find longest word in the sentence
Find the first occurence of number in the sorted array
Flatten nested javascript array