Regular expression for file and directory listing

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

Finding missing numbers from billion sequential number list file

Check if there are three numbers a, b, c giving a total T from array A

Array reversal in Recurrsion

Get maximum occurring character

Changing decimal number to its binary equivalent

Implement Queue Using two Stacks – JavaScript algorithm

String Ordered Permutation Algorithm Problem

Find longest palindrom from sequence of characters

find longest word in the sentence

Find the pairs that makes K Complementary in the given array java solution

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*