Shell script: For loop unexpected output -


i have requirement have read names of sub directories , copy names file. following code have written.

 file in $home/autoqa/screenshots/*   if [ -d "$file" ];              echo "$file" >> $home/autoqa/failedtestcases.txt   fi done  

now above code works output

/home/autoqa/screenshots/1 /home/autoqa/screenshots/2 ...... 

but expect follows

1 2 .... 

so need names of sub directories. here before running loop, dont want

cd /home/autoqa/screenshots/ 

how can manage that? can help?

replace line

echo "$file" >> $home/autoqa/failedtestcases.txt 

with

basename "$file" >> $home/autoqa/failedtestcases.txt 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -