LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-05-2013, 04:17 PM   #1
Drigo
Member
 
Registered: May 2009
Posts: 111

Rep: Reputation: 17
ls to list files withouth my key word!


lets say I have 1k *.dcm files and 2 *.<other formats>....I want a command that will output the *.<other_formats>.

For example:

$ls !(or something that does the not) *.dcm
that gives me:
*.x
*.y
*.z
 
Old 02-05-2013, 04:22 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,406

Rep: Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019
Code:
ls -I '*.dcm'
 
Old 02-05-2013, 04:32 PM   #3
Drigo
Member
 
Registered: May 2009
Posts: 111

Original Poster
Rep: Reputation: 17
Not working...

$ls -I '*.dcm'
ls: ilegal option -- I
usage: ls [-ABCD...] [file...]
 
Old 02-05-2013, 05:09 PM   #4
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 592

Rep: Reputation: 140Reputation: 140
Quote:
Not working...
Which shell do you use. Works for bash.
 
Old 02-05-2013, 05:15 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
A find alternative:
Code:
find . -maxdepth 1 -type f -not -name \*.dcm
the -maxdepth 1 option limits the results to the current working directory (if needed).
 
Old 02-05-2013, 05:19 PM   #6
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 7,973
Blog Entries: 11

Rep: Reputation: 2167Reputation: 2167Reputation: 2167Reputation: 2167Reputation: 2167Reputation: 2167Reputation: 2167Reputation: 2167Reputation: 2167Reputation: 2167Reputation: 2167
Code:
$\ls -I '*.dcm'
just in case an existing alias is mucking it up?

Code:
type -t ls
or even
Code:
type ls
will show.
 
Old 02-05-2013, 06:05 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,338
Blog Entries: 55

Rep: Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538
I prefer using 'find but "modern" incarnations of 'ls' seem to have a "--hide=" switch so '\ls --hide=*.dcm;' could work.
 
Old 02-05-2013, 06:10 PM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,406

Rep: Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019
Quote:
Originally Posted by Drigo View Post
Not working...

$ls -I '*.dcm'
ls: ilegal option -- I
usage: ls [-ABCD...] [file...]
Is this an embedded or very old system? Even my 8 year old Fedora 4 machines have the -I flag in ls. But if this is something like Busybox then it may be running a stripped down version of ls with less functionality. In that case, we need to know what you're running before we can suggest a working alternative.
 
Old 02-05-2013, 07:41 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,326

Rep: Reputation: 2364Reputation: 2364Reputation: 2364Reputation: 2364Reputation: 2364Reputation: 2364Reputation: 2364Reputation: 2364Reputation: 2364Reputation: 2364Reputation: 2364
If you do have a really basic version of Linux, this should work
Code:
ls | grep -v '.dcm'
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i need to access a disk-on-key with MS word/Excell files on it ahartman Linux - Hardware 5 03-23-2010 05:22 AM
How can i read two files word by word at a time using any loop by shell script? vaibhavs17 Programming 16 03-19-2010 03:48 AM
word by word comparison in two files using loop in shell script vaibhavs17 Programming 2 03-05-2010 07:41 AM
Word list generation (all combinations) from a list of characters llattan Linux - Newbie 1 04-07-2009 07:41 PM
The HorizSync key word must followed by a list of numbers or ranges comox *BSD 2 03-14-2005 03:57 AM


All times are GMT -5. The time now is 03:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration