Having trouble listing the contents of a folder I’m not in, while excluding the actual folder name itself.
ex:
root@vps [~]# find ~/test -type d
/root/test
/root/test/test1
However I want it to only display /test1, as the example.
Thoughts?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do that with
-execandbasename:Explanation:
find ~/test -type dpart finds all directories recursively under~/test, as you already know.-exec basename {} \;part runs thebasenamecommand on{}, which is where all the results from the last step are substituted into.