LinuxQuestions.org
Review your favorite Linux distribution.
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, 05:17 PM   #1
Drigo
Member
 
Registered: Jun 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, 05:22 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,260

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Code:
ls -I '*.dcm'
 
Old 02-05-2013, 05:32 PM   #3
Drigo
Member
 
Registered: Jun 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, 06: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, 06:15 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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, 06:19 PM   #6
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,195
Blog Entries: 10

Rep: Reputation: 1986Reputation: 1986Reputation: 1986Reputation: 1986Reputation: 1986Reputation: 1986Reputation: 1986Reputation: 1986Reputation: 1986Reputation: 1986Reputation: 1986
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, 07:05 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
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, 07:10 PM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,260

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
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, 08:41 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
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 06: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 04:48 AM
word by word comparison in two files using loop in shell script vaibhavs17 Programming 2 03-05-2010 08:41 AM
Word list generation (all combinations) from a list of characters llattan Linux - Newbie 1 04-07-2009 08:41 PM
The HorizSync key word must followed by a list of numbers or ranges comox *BSD 2 03-14-2005 04:57 AM


All times are GMT -5. The time now is 08:33 AM.

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