How to use ls command with cd recursively

shell-script

I have a requirement where I need to validate the nested folder structure.

Ex: I have 3 folders: test1, test2, test3 (Practically there can be anynumber of such folders). Now all these folders should contain folder like V1, V2… like that ('V' followed by number). Under this folder (V1… ), there should be only two folders names 'dummy1' and 'dummy2'.

So all these checks should be done recursively until all the folders like test 1… test2… Are checked.

Best Answer

You could use the find command. Find recurses through a directory structure doing things to each file/directory. You can limit it to directories with the -type flag.

find start_dir -type d -print

To actually validate all have the structure I think you are going to have to write a script looking at this list - and I think you would have to do this in a more powerful scripting language than shell e.g. perl, python, ruby, tcl.