LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ls to list files withouth my key word! (https://www.linuxquestions.org/questions/linux-newbie-8/ls-to-list-files-withouth-my-key-word-4175448758/)

Drigo 02-05-2013 04:17 PM

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

suicidaleggroll 02-05-2013 04:22 PM

Code:

ls -I '*.dcm'

Drigo 02-05-2013 04:32 PM

Not working...

$ls -I '*.dcm'
ls: ilegal option -- I
usage: ls [-ABCD...] [file...]

whizje 02-05-2013 05:09 PM

Quote:

Not working...
Which shell do you use. Works for bash.

colucix 02-05-2013 05:15 PM

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).

Habitual 02-05-2013 05:19 PM

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. :)

unSpawn 02-05-2013 06:05 PM

I prefer using 'find but "modern" incarnations of 'ls' seem to have a "--hide=" switch so '\ls --hide=*.dcm;' could work.

suicidaleggroll 02-05-2013 06:10 PM

Quote:

Originally Posted by Drigo (Post 4885062)
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.

chrism01 02-05-2013 07:41 PM

If you do have a really basic version of Linux, this should work
Code:

ls | grep -v '.dcm'


All times are GMT -5. The time now is 07:49 AM.