How do I get absolute path from using find unix command
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
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.