I want to list all the directories that start with . in the current directory. I don't want the previous directory (..) to be listed so I had the regular expression something like this. I am using csh
ls .[^.]*
It works fine on UNIX variant platforms but in solaris, I am still using the csh but it lists me only .. directory. How can I specify the regular expression with the exact functionality in Solaris. It works in bash but I have to use csh only as it is guaranteed to be available on each SOLARIS box in our org.
You can do this with /bin/sh
, but with a slightly different syntax; it uses !
rather than ^
to negate the set of characters:
ls .[!.]*
Note that this is a file matching pattern (a glob), not a regular expression.
But given the variations you're seeing in the glob syntax supported by various shells, you might be better off using grep
with actual regular expressions.