![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 301
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
"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?
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() ![]() |
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.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 3
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Attitudes | Oddball | Coder's Corner Lounge | 29 | Mar 18th, 2006 9:34 PM |
| C++ template and namespace question | Soulstorm | C++ | 3 | Jan 22nd, 2006 2:46 PM |
| How to post a question | nnxion | C++ | 10 | Jun 3rd, 2005 11:53 AM |
| How to post a question | nnxion | C++ | 0 | Jun 3rd, 2005 8:55 AM |
| How to post a question | nnxion | C | 0 | Jun 3rd, 2005 8:55 AM |