Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to get absolute path by using find command.
actually I am running the following script:-

find . -size +20M | while read a
     i=$(echo $a | sed 's:/: :g')
     echo $a;

but here variable $a showing path starting from ./Downloads/filename but I want absolute path from /.

share|improve this question
up vote 11 down vote accepted

Use find with an absolute path.

find /path/ -size +20M

It will print the whole path.
If you do not know the working directory then use command substitution for pwd like this:

find "`pwd`" -size +20M 
   #or like this:
find "$(pwd)" -size +20M

To get your working directory

Anyway, it seems that Bash man now advise to use $() over `` so you should use the second form. You can also probably refer directly to the $PWD variable that contains the working directory of your script and it would be probably faster if you have to use in a loop.

find "$PWD" -size +20M
share|improve this answer
But i donot have path, I only have . as current directory then? – Devavrata Apr 21 '14 at 9:38
Don't start with ., use $(pwd) instead, that will give you a full path. – bsd Apr 21 '14 at 9:40

You can use the pwd command or print out the file realpath:

$ find "$(pwd)" -size +20M
$ find . -size +20M -exec realpath {} +

Both commands real give you the absolute path to the files.

share|improve this answer
But 2nd one is giving find: `realpath': No such file or directory – Devavrata Apr 21 '14 at 9:57
Hum. Maybe you don't have it installed although it is provided by the coreutils package. Try to locate it with which realpath. – Spack Apr 21 '14 at 10:02
It is locating nothing.. – Devavrata Apr 21 '14 at 10:03
Which system are you using? – Spack Apr 21 '14 at 10:18
Linux BANE 3.7-trunk-amd64 #1 SMP Debian 3.7.2-0+kali8 x86_64 GNU/Linux – Devavrata Apr 21 '14 at 10:22

To List all PNG and JPEG files which are 7 days old with absolute path.

$ find $PWD/ -mtime -7 -print -exec grep -e ".png\|.jpg" {} \;

Here $PWD will be added to every file matched.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.