LinuxQuestions.org
Help answer threads with 0 replies.
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-10-2011, 07:08 AM   #1
hexapla
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Rep: Reputation: Disabled
Complex commands


Hi guys,

can you please help me with an issue that i encountered?

I have to list all files (their full paths) in /tmp/test/ and subdirectories, that contain the left bracket "[" .

I used find $PWD -name \*[\* but it is not working becuase [ is a special character and I don't now how to escape it.

I am using Oracle Enterprise 5.

Thanks!!!
 
Old 10-10-2011, 07:42 AM   #2
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.0 + 14.1
Posts: 4,834

Rep: Reputation: 431Reputation: 431Reputation: 431Reputation: 431Reputation: 431
Your command worked for me, I copied it, pasted it, pressed enter, it worked...

Quote:
find $PWD -name \*[\*
/home/cliff/.cache/vlc/art/artistalbum/ACDC/AC_DC Live [1992]
This link describes the escape sequence, as far as I can see, you have it O.K.

Possibly you don't have an entry with a [ barce?
 
Old 10-10-2011, 07:50 AM   #3
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Quote:
Originally Posted by hexapla View Post
Hi guys,

can you please help me with an issue that i encountered?

I have to list all files (their full paths) in /tmp/test/ and subdirectories, that contain the left bracket "[" .

I used find $PWD -name \*[\* but it is not working becuase [ is a special character and I don't now how to escape it.

I am using Oracle Enterprise 5.

Thanks!!!
Hello and Welcome to LinuxQuestions,

It worked for me too so I suppose it's something that your shell cannot handle. Try putting the regex between '' like this:
Code:
find $PWD -name '*\[*'
Looking forward to your participation in the forums. Have fun with Linux.

Kind regards,

Eric
 
Old 10-10-2011, 08:25 AM   #4
hexapla
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
it worked thank you
 
Old 10-10-2011, 08:44 AM   #5
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hi,

You're welcome. If you consider your problem solved, then please mark this thread as such. Have fun with Linux.

Kind regards,

Eric
 
Old 10-10-2011, 12:59 PM   #6
hen770
Member
 
Registered: Oct 2010
Distribution: Arch
Posts: 136

Rep: Reputation: 7
just for my clearness, what is the * after the \ ?
as far as i know the \ is the escape character, and here we want to escape the [ and not the *?

Thanks.
 
Old 10-10-2011, 01:06 PM   #7
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,604

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
Quote:
Originally Posted by hen770 View Post
just for my clearness, what is the * after the \ ?
as far as i know the \ is the escape character, and here we want to escape the [ and not the *?

Thanks.
Hi,

you also need to protect the asterisk from bash expansion. So you either have to escape or quote it. The '[' is also a special character and therefore it will be interpreted as characterclass by find. So if you want a literal match then you need to escape it for 'find'. 'find' has its own gobbing mechanism.

BTW, this also worked:
Code:
find . -name \*\\[\*
 
  


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
Complex routing axelgenus Linux - Networking 7 05-19-2010 12:28 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - Software 2 07-02-2008 06:26 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - General 2 07-01-2008 06:53 AM
complex password sachin1361 Linux - Enterprise 2 04-01-2008 02:46 AM
gsl_complex vs <complex> darknails Programming 0 02-27-2005 10:24 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration