Issue
dev1.ab.com is the current server, I have to ssh to tes1.ab.com, move inside the path /spfs/tomcat/dir and list all the directories (no files) present there.
For this I am using the below command from the command line of dev1.ab.co
*ssh tes1.ab.com " ls -1d / /spfs/tomcat/dir "
but in output I am getting output the directories of home is /spfs/tomcat, I have also tried
*ssh tes1.ab.com " ls -lrt /spfs/tomcat/dir | ls -1d /"
*ssh tes1.ab.com " cd /spfs/tomcat/dir | ls -1d /"
and ended up with nearly same result.
can someone help me to write a command in command line of dev1.ab.com to ssh to tes1.ab.com and get the output as the list of directories present in /spfs/tomcat/dir directory.
Solution
Use find
instead of ls
.
ssh tes1.ab.com "find /my/folder -type d"
add -maxdepth 1
to list only the first level
Answered By - pkuhar Answer Checked By - Timothy Miller (WPSolving Admin)