LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-28-2013, 08:45 PM   #1
angel'le
LQ Newbie
 
Registered: Apr 2012
Distribution: Gentoo, Arch
Posts: 21

Rep: Reputation: Disabled
ls: cannot access *.{jpg,png}: No such file or directory


when I type:
Code:
ls *.{jpg,png}
It outputs:
Code:
ls: cannot access *.jpg: No such file or directory
ls: cannot access *.png: No such file or directory
I want to list all files which ends in .jpg and .png
What is wrong?

Last edited by angel'le; 09-28-2013 at 09:24 PM. Reason: wrong title
 
Old 09-28-2013, 08:58 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Apparently there are no jpg or png files in the directory...

What do you get when you type ...

Code:
ls *jpg
ls *png
 
1 members found this post helpful.
Old 09-28-2013, 09:05 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Works for me if there are files with those extensions present in the current directory. Are the files in the current directory? What shell are you using? (Responsibility for expanding the "*" lies with the shell.)
 
1 members found this post helpful.
Old 09-28-2013, 09:10 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Another approach, if you want to find all you image files in all your directories (under your current working directory):
Code:
$ find ./ -type f '(' -iname '*.jpg' -or -iname '*.png' ')' | head
./.minecraft/config/CraftGuide/themes/base/base.png
./.minecraft/config/CraftGuide/themes/dark/dark_brew.png
./.minecraft/config/CraftGuide/themes/dark/dark_craft.png
./.minecraft/config/CraftGuide/themes/dark/dark.png
./.minecraft/debug.stitched_items.png
./.minecraft/debug.stitched_terrain.png
./Books/Friedman, David D/Harald/141652056201.jpg
./Books/Friedman, David D/Harald/1416520562.jpg
./Books/Van Vogt, A. E./Transgalactic/1416520899.jpg
./Books/Lisle, Holly/Fire in the Mist/0671721321.jpg
(I piped this into head so I wouldn't need to post several thousand lines. )
 
1 members found this post helpful.
Old 09-28-2013, 09:11 PM   #5
angel'le
LQ Newbie
 
Registered: Apr 2012
Distribution: Gentoo, Arch
Posts: 21

Original Poster
Rep: Reputation: Disabled
There were not files, I didn't know it outputs errors.
ls *.{jpg,png} 2> /dev/null
Thank you, all I have to do is redirect stderr to /dev/null
 
Old 09-28-2013, 09:21 PM   #6
angel'le
LQ Newbie
 
Registered: Apr 2012
Distribution: Gentoo, Arch
Posts: 21

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by PTrenholme View Post
Another approach, if you want to find all you image files in all your directories (under your current working directory):[code]
$ find ./ -type f '(' -iname '*.jpg' -or -iname '*.png' ')' | head
It is good, maybe I'll use it
 
  


Reply



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
Want to make a bash script that removes a png file if a jpg has the same name. kebertx Linux - Newbie 2 06-21-2012 11:37 PM
Program to determine if a file is a valid image (jpg, png, gif, etc.) KDHofAvalon Linux - Software 7 06-09-2009 04:54 PM
Converting .png to .jpg GtkUser Linux - Software 9 04-17-2007 02:04 PM
jpg files has no preview in file tips, png does. Acidx Linux - Desktop 1 10-15-2006 01:52 PM
pnp to png or jpg illtbagu Linux - Newbie 1 01-26-2003 03:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:28 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
Open Source Consulting | Domain Registration