unix - Shell Scripting Bug - dot printed after file name when argument is passed -


i have code when passed 2 arguments: file name , folder name prints out dot file when should print name of parameter.

something array argument using @ line 3 giving me result:

  • for each in "${data[@]}"

if take away find instead using data=$(find f*), use data=$* print file name , folder name, want file contents inside folder(directory) printing blanks.

source code

data=$(find $*) amount=$(find $* | wc -l) each in "${data[@]}" sett=(${each[$i]}) done count=0 while [ $count -lt $amount ] echo "do want remove: ${sett[$count]}" read ans if [ $ans = y ] echo "" elif [ $ans = n ] echo "" fi done 

when passed arguments using data=$(find $*):

sh filewithcode fileinteractingwith folderinteractingwith

prints out:

  • do want remove: .
  • do want remove: directoryname
  • do want remove: directoryname/file1
  • do want remove: directoryname/file2

when using data=$*

prints out:

  • do want delete: file name
  • do want delete: folder name
  • do want delete: [blank]
  • do want delete: [blank]

expected output:

  • do want delete: file name
  • do want delete: folder name
  • do want delete: folder name/file name1
  • do want delete: folder name/file name2

i using putty programmer.

thanks in advance


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -