Reputation: 33
I am trying to get full path of both the files and directories from a directory. I tried using find but unable to get result.
when I used find /home/demo -type f it only lists files and find /home/demo -type d only lists directories.
Is there a way to get both using Find?
Upvotes: 0
Views: 101
Reputation: 75478
You can specify the absolute path of a directory. As an example for the current directory:
find "`pwd`"
pwd
shows full path of current directory. ` `
summons a subshell in which output can be used as an argument to the command.
A literal example can be:
find /home/user
Update: You can use -o
to explicitly target both files and directories. Doing find
without an option may include other types besides the two.
find /home/user \( -type f -o -type d \)
Note: -or
is synonymous but may not work in other versions of find
since it's not POSIX compliant.
Upvotes: 2