LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 10-12-2012, 01:08 PM   #1
catalys
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Rep: Reputation: 0
Syntax for ls with Ignore pattern?


I would like my ls command to exclude files ending with a particular extension, e.g. hoh, so that I do not have to pipe the result to a grep command.

Apparently this can be done with the -I (Ignore) option, but what is the correct syntax?

All these attempts failed (ALL the current folder files were listed):
ls -I[hoh$]
ls -I [hoh$]
ls -I/hoh$/
ls -I /hoh$/

(If only the "--help" function had examples...)

Thanks!

Last edited by catalys; 10-12-2012 at 01:13 PM.
 
Old 10-12-2012, 01:13 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Code:
ls -I '*hoh'
 
1 members found this post helpful.
Old 10-12-2012, 01:47 PM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
You can achive this by using:
ls -la *.<extension>
For example, ls -la *.hoh
 
  


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
Help needed for diff to ignore a line with certain pattern rockf1bull Red Hat 6 10-04-2011 11:41 AM
[SOLVED] /bin/bash if statement pattern search, end of pattern special character? headhunter_unit23 Programming 3 04-29-2010 08:05 AM
setting IFS to ignore pattern eRJe Programming 3 03-12-2010 04:20 AM
[SOLVED] Adding (not replacing) a pattern match with a similar pattern? b-bri Linux - Newbie 2 08-31-2009 12:36 AM
What is the Package Search pattern Syntax for dpkg --list? Akhran Debian 3 08-23-2005 05:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:41 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