Question

How can I do that? Do I have to use regular expressions?

To clarify, let's say I have the following files in a directory: abc.sh acb.sh example.c bob.php - and I want to list the ones which has 'c' as second letter (i.e. acb.sh).

Thanks!

Was it helpful?

Solution

If you are working in the shell

ls ?c*

is all that it takes.

OTHER TIPS

What about

ls ?c*

I guess it will do.. question mark stands for single character.

ls | grep "^.c"

Also works, here ^ indicates beginning of line, so ^. says match any single character at beginning and then match c.

Also you can use find command:

find ./ -name "?c*.*"
ls . | grep '^.c'

where . represents the present working directory

or

find / -type d -exec grep '^.c' {};

or

find / -type d | grep '^.c'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top