LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 05-11-2017, 10:52 AM   #1
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
displaying full path using find in multiword directories


I know that normally if I want to make find show the full path of a file, while I'm in any subdirectory (such as /home/user), I can do something like this:
Code:
find `pwd` -iname "whatever"
The problem is that, if I'm in a directory that contains several words, I get an error. For instance:
Code:
find `"pwd"` johnrsnf.txt
find: ‘/home/quas/lynda/awk’: No such file or directory
find: ‘Exercise’: No such file or directory
find: ‘Files’: No such file or directory
johnrsnf.txt
So how do I proceed in this case?
 
Old 05-11-2017, 11:33 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
You need the quotes around the results of the back ticks - you have it the other way. It should be:

Code:
find "`pwd`"
You can also do the newer way:
Code:
find "$(pwd)"
That's a little cleaner as it eliminates confusion between back ticks and single quotes (or double quotes).

Last edited by MensaWater; 05-11-2017 at 11:34 AM.
 
Old 05-11-2017, 12:18 PM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243
adding the -name {fileName} to find eliminates everything it is looking at. Unless you like watching it do that.
Code:
userx%slackwhere ⚡ scripts ⚡> find $(pwd) -name testfile
/home/userx/scripts/testfile
 
Old 05-11-2017, 12:20 PM   #4
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
There was a mistake in my post. Of course, I meant to write -iname or -name, otherwise it wouldn't have made much sense.
Anyway, thanks, Mensa, I was placing the quotes inside instead of outside.
 
  


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
[SOLVED] Installing an extra version of CMake - can run from full path but not from $PATH mattachu Linux - Software 1 05-23-2014 04:58 PM
ls: displaying the whole path. stf92 Linux - Newbie 10 06-09-2010 12:15 PM
how can i find full path of file? DoME69 Programming 5 03-04-2009 03:11 PM
how to find full path for soft links bkcreddy17 Linux - Newbie 6 11-17-2008 01:03 PM
How-to : get full path of each file after applying find and cut kaprasanna Linux - General 1 01-07-2008 02:19 AM

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

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