Try doing this :
$ printf '%s\n' "${my_array[@]}"
The difference between $@
and $*
:
- Unquoted, the results are unspecified. In Bash, both expand to separate args and then wordsplit and globbed.
- Quoted,
"$@"
expands each element as a separate argument, while"$*"
expands to the args merged into one argument:"$1c$2c..."
(wherec
is the first char ofIFS
).
You almost always want "$@"
. Same goes for "${arr[@]}"
.
Always quote them!
Related Posts:
- How to split a string into an array in Bash?
- How to split a string into an array in Bash?
- What is a list in Bash?
- How to sort an array in Bash
- Converting array to list in Java
- What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
- Java Error “Exception in thread “main” java.util.InputMismatchException” On an Array program
- How to print elements in a vector c++
- TypeScript Objects as Dictionary types as in C#
- Data type not understood while creating a NumPy array
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- Are vectors passed to functions by value or by reference in C++
- How do I declare a 2d array in C++ using new?
- “error: assignment to expression with array type error” when I assign a struct field (C)
- Does JavaScript have a method like “range()” to generate a range within the supplied bounds?
- Getting “conflicting types for function” in C, why?
- Loop through an array of strings in Bash?
- Javascript Uncaught TypeError: Cannot read property ‘0’ of undefined
- Does JavaScript have a method like “range()” to generate a range within the supplied bounds?
- Form submission: PHP S_SESSION statements within a foreach loop
- Working with a List of Lists in Java
- Array Size (Length) in C#
- Getting “conflicting types for function” in C, why?
- How to convert jsonString to JSONObject in Java
- Array of arrays (Python/NumPy)
- what does “>>>” mean in java?
- How to convert List
to int[] in Java? - Calculating Standard Deviation & Variance in C++
- Javascript Uncaught TypeError: Cannot read property ‘0’ of undefined
- How to convert int[] into List
in Java? - What does ** do in C language?
- Correct way of looping through C++ arrays
- When will the worst case of Merge Sort occur?
- In Java, how to append a string more efficiently?
- How do I create an array of strings in C?
- ow to create a histogram in java
- what does .space do in mips?
- How do I remove an array item in TypeScript?
- What does << mean in Ruby?
- How to create an array of strings in C?
- Initialization from incompatible pointer type warning when assigning to a pointer
- Bubble sort algorithm in MIPS
- Error: unsupported use of matrix or array for column indexing
- Using multiple variables in a for loop in Python
- Weighted random selection from array
- Badly placed ()’s error with the following shell script
- type any? has no subscript members
- Multidimensional Vectors in C++
- Java ArrayList for integers
- java.lang.ArrayIndexOutOfBoundsException: 4 Error
- IndexError: index 10 is out of bounds for axis 0 with size 10
- Multi-dimensional arrays in Bash
- How can I find the number of elements in an array?
- Array type char[] is not assignable
- Two-dimensional array in Swift
- Parameter name omitted error?
- C char array initialization
- How to iterate through table in Lua?
- How to sort in-place using the merge sort algorithm?
- VBA array sort function?
- How to declare and use 1D and 2D byte arrays in Verilog?
- Difference between char *argv[] and char **argv for the second argument to main()
- Convert ArrayList
to java.util.List [closed] - Dynamic vs static array in c
- Array to Hash Ruby
- Java says this method has a constructor name
- Create an empty object in JavaScript with {} or new Object()?
- GCC: Array type has incomplete element type
- What is the best way to delete a value from an array in Perl?
- Checking if a key exists in a JavaScript object?
- variably modified array at file scope in C
- Numpy matrix to array
- Using the Pythagorean theorem with Java
- Return array in a function
- Error : Index was outside the bounds of the array.
- char *array and char array[]
- How do I iterate over a range of numbers defined by variables in Bash?
- Echo newline in Bash prints literal \n
- How do you check if a variable is an array in JavaScript?
- warning: ISO C++ forbids variable length array
- How do I create an array of strings in C?
- How can I get the source directory of a Bash script from within the script itself?
- cp: missing destination file operand after
- BASH Syntax error near unexpected token ‘done’
- Ternary operator (?:) in Bash
- Pseudo-terminal will not be allocated because stdin is not a terminal
- How to escape single quotes within single quoted strings
- Are arrays passed by value or passed by reference in Java?
- How to convert a string to lower case in Bash?
- Numpy.dot TypeError: Cannot cast array data from dtype(‘float64’) to dtype(‘S32’) according to the rule ‘safe’
- How to modify a global variable within a function in bash?
- extended initializer lists only available with
- Sorting data based on second column of a file
- struct has no member named
- Most efficient method to groupby on an array of objects
- Mysql where id is in array
- How to convert UTF-8 byte[] to string
- How do I store an array in localStorage?
- C: warning: excess elements in array initializer; near initialization for ‘xxx’ ; expects ‘char *’, but has type ‘int’
- C++ float array initialization