List of all files, not starting from the number

I want to examine all the key files present in my /proc . But /proc has countless directories matching running processes. I do not want these directories to be listed. All names of these directories contain only numbers. How bad am I in regular expressions, can someone tell me that I need to send regex to ls to make it NOT to search for files / directories that have numbers on their behalf?

UPDATE : thanks to all the answers! But I would like to have only ls solution instead of ls+grep solution. The ls solutions offered so far do not seem to work!

+8
linux regex shell ls
source share
6 answers

All files and directories in /proc that do not contain numbers (in other words, excluding process directories):

 ls -d /proc/[^0-9]* 

All files are recursively located under /proc , which do not start with a number:

 find /proc -regex '.*/[0-9].*' -prune -o -print 

But it also excludes numerical files in subdirectories (e.g. /proc/foo/bar/123 ). If you want to exclude only top-level files with a number:

 find /proc -regex '/proc/[0-9].*' -prune -o -print 

Hold on again! Does this not mean that any regular files created by touch /proc/123 or the like will be excluded? Theoretically, yes, but I don’t think you can do it. Try creating a file for a PID that does not exist:

 $ sudo touch /proc/123 touch: cannot touch `/proc/123': No such file or directory 
+6
source share

You don't need grep, just ls :

 ls -ad /proc/[^0-9]* 

if you want to find the whole subdirectory structure, use find:

 find /proc/ -type f -regex "[^0-9]*" -print 
+7
source share

Use grep with -v , which tells it to print all lines that don't match the pattern.

  ls /proc | grep -v '[0-9+]' 
+2
source share

ls /proc | grep -v -E '[0-9]+'

+1
source share

The following regular expression matches all characters except numbers

 ^[\D]+?$ 

Hope this helps!

0
source share

For the sake of completion. You can apply the Mithandir answer with find.

  find . -name "[^0-9]*" -type f 
0
source share

All Articles