Shell automatically obtains the first-level directory and the second-level directory

Shell automatically obtains the first-level directory and the second-level directory

#!/bin/sh
function getdir()
{
    
    
    for file in $1/*
		do		
		   if [ -d $file ]
		   then 
				var=$file
				#path=`dirname $var`
				path=`cd "$path$var"; pwd`				
				cd $path
				ls $path			
				unset path
				cd ..
		   fi
		done
}
getdir .

Guess you like

Origin blog.csdn.net/weixin_44322234/article/details/109039403