Question: I have this code : 

```
for file in "$@"*png; do
  echo "$file"
done

```

It works only if you provide a path that ends with / like `/root/`. 

What would be the correct way to add / to the path input, in situations like this, without breaking my script? 

If you give a path input without / at the end, it just does this : 

```
File: /root*png

```

If I modify it to be `for file in "$@"/*png; do` and input `/root/test/` it works but the result looks ugly : 

```
File: /root/test//sample2.png

```

Answer: 
Using `$@` with the glob like that seems somewhat odd. If you expect it to be able to process multiple arguments, well, it won't work. The strings surrounding `$@` are only attached to the first and list item.

```
$ mkdir a b; touch a/a.png b/b.png
$ set -- a b 
$ echo x"$@"x
xa bx
$ echo "$@/"*.png
a b/b.png

```

So, to handle multiple arguments, you'll need to loop over `"$@"` separately:

```
for arg in "$@"; do
    for file in "${arg%/}"/*.png; do
         echo "$file"
    done 
done

```

In another case, you could you could use the string substitution expansion `${//}` (in Bash or zsh) to add a suffix to each positional parameter, but it's rather difficult to get that to work with a glob.
You can use tr too.

Always add / at the end and ...

```
file='/root/test//sample2.png';echo "$file" | tr -s '/'

```