LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 02: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 02:13 PM.
 
Old 10-12-2012, 02:13 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,355

Rep: Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989Reputation: 1989
Code:
ls -I '*hoh'
 
1 members found this post helpful.
Old 10-12-2012, 02: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


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


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