Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 8th, 2007, 11:50 AM   #1
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 327
Rep Power: 4 cwl157 is on a distinguished road
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
cwl157 is offline   Reply With Quote
Old Feb 8th, 2007, 12:12 PM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
"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?
Arevos is offline   Reply With Quote
Old Feb 9th, 2007, 8:56 AM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,464
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Feb 9th, 2007, 3:44 PM   #4
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
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.
jim mcnamara is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:55 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC