Skip to main content
1 of 2
toliveira
  • 347
  • 3
  • 11

Bash script parsing argument with quotes

Please consider this simple script named test:

#!/bin/bash
echo $1

and the following commands and calls:

$ echo "A B"
A B
$ echo ""A B""
A B
$ echo """A B"""
A B
$ echo """A B"""
A B

$ ./test "A B"
A B
$ ./test ""A B""
A
$ ./test """A B"""
A B
$ ./test """"A B""""
A

Could someone please explain why the call of test doens't behave like the command echo or point to the relevant documentation?

toliveira
  • 347
  • 3
  • 11