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?
You can use combination of ls command, find command, and grep command to list directory names only. You can use the find command too.
The top-most directory in such a filesystem, which does not have a parent of its own, is called the root directory.
You can use the DIR command by itself (just type “dir” at the Command Prompt) to list the files and folders in the current directory.
Substitute dir /A:D. /B /S > FolderList. txt to produce a list of all folders and all subfolders of the directory. WARNING: This can take a while if you have a large directory.
There's nothing wrong with a simple
find ~/test -mindepth 1
Similarly, this will have the same effect:
find ~/test/*
as it matches everything contained within ~/test/
but not ~/test
itself.
As an aside, you'll almost certainly find that find
will complain about the -mindepth n
option being after any other switches, as ordering is normally important but the -(min|max)depth n
switches affect overall behaviour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With