![]() |
ls question
Does anyone know how to write the command for listing all files in a folder except the file tt using ls and meta characters? I have tried ls [^tt]* but this lists all files in the sub directories also and I don't want that i just want all the files in the current directory.
Thanks |
"ls -d" will display directories without displaying their contents. However, I don't think globs support "not" clauses like "^tt". Perhaps you should pipe the output through a more sophisticated filter, like grep?
|
If this isn't some sort of an metacharacter assignment, you could always do this:
ls | grep -v tt Also, ls [^tt]* works in /bin/bash. |
In ksh and bash you can use a limited form of regex called pattern-matching
ls *.c lists all of the file that have a . followed by the letter c ls *.[!c] lists all of the files that have a do and do not end in c the [c] thing is a class of characters. The [!c] means not this class of characters. You can also do ls *.[Oo] This lists files that end in O or o. This is all part of globbing in shell. |
| All times are GMT -5. The time now is 10:19 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC