1753758 Members
4607 Online
108799 Solutions
New Discussion юеВ

Re: Wild cards

 
Md.Shahabuddin
Advisor

Wild cards

How to list files with various combinations of wild cards i.e. files with 6 char length, files with extensions, without extensions, files / directories with specific word etc.
4 REPLIES 4
mobidyc
Trusted Contributor

Re: Wild cards

Hello,

6 char listing
#> /bin/ls -1 |awk '{ if( length($0) == 6 ) { print $0 ; } else { next ; } }'

list only files with extension
#> /bin/ls |egrep "[[:alnum:]].*[[:alnum:]]\.[[:alnum:]].*[[:alnum:]]"

list only files without extension
#> /bin/ls |egrep -v "[[:alnum:]].*[[:alnum:]]\.[[:alnum:]].*[[:alnum:]]"

list / dir for files with word 1 or word 2 in the filename
#> ls / |egrep "word1|word2"

For more informations, you coyuld ask your friend, google.com.

Regards,
Cedrick Gaillard
Best regards, Cedrick Gaillard
Ralph Grothe
Honored Contributor

Re: Wild cards

six char length files can be listed easily by csh type globbing (also works for bourne/posix of course)

echo ??????

Madness, thy name is system administration
Ralph Grothe
Honored Contributor

Re: Wild cards

Also, dirs with e.g. words samba and open in name:

$ ls -dp /opt/*{samba,open}*|grep /\$
/opt/openssl/
/opt/samba/
/opt/samba_src/
Madness, thy name is system administration
Md.Shahabuddin
Advisor

Re: Wild cards

Thanks folk !!!!!