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-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
LQ 5k Club
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 15.0, current, slackware-arm-currnet
Posts: 6,215

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
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
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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



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

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

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