#!/bin/sh
function getdir(){
for element in `ls $1`
do  
	dir_or_file=$1"/"$element
	if [ -d $dir_or_file ]
	then 
		if [ "$dir_or_file" == $1"/rpms" ]
		then
			continue
		fi
		getdir $dir_or_file
	else
		if [[ $dir_or_file =~ ".rpm" ]]
		then
			file=${dir_or_file##*/}
			echo $file
			ln -s $dir_or_file rpms/$file
		fi
	fi
done
}

getdir "/data/nginx/cmigrate/kernel-devel"
