It is a small error.
arr= (one two three)
should’ve been
arr=(one two three)
Also you can’t use \n
in echo
. Use printf
if you want to use \n
.
And fixing the rest of the errors, the code looks like this.
# array declaration arr=(one two three) # for loop for (( i=0;i<3;i++ )) do printf "\n $((i+1)) : ${arr[i]}" done echo ""
Related Posts:
- What is a list in Bash?
- Using multiple variables in a for loop in Python
- How to sort an array in Bash
- Loop through an array in JavaScript
- How to split a string into an array in Bash?
- Loop through an array in JavaScript
- Converting array to list in Java
- What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
- Ubuntu says “bash: ./program Permission denied” [closed]
- 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?
- How do I iterate over a range of numbers defined by variables 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
- How to split a string into an array in Bash?
- How do I iterate over a range of numbers defined by variables in Bash?
- Working with a List of Lists in Java
- Array Size (Length) in C#
- Getting “conflicting types for function” in C, why?
- How can I declare and use Boolean variables in a shell script?
- How to convert jsonString to JSONObject in Java
- How can I declare and use Boolean variables in a shell script?
- Array of arrays (Python/NumPy)
- Shell Script Syntax Error: Unexpected End of File
- Why is using “for…in” for array iteration a bad idea?
- what does “>>>” mean in java?
- How to convert List
to int[] in Java? - Calculating Standard Deviation & Variance in C++
- Error: can only iterate over an array or an instance of java.lang.Iterable
- 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
- What does the line “#!/bin/sh” mean in a UNIX shell script?
- 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?
- What is the difference between ( for… in ) and ( for… of ) statements?
- Fill array with random numbers within a specified range (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
- How to read a file into a variable in shell?
- Weighted random selection from array
- type any? has no subscript members
- Simple average function in Javascript
- 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
- What does set -e mean in a bash script?
- What does set -e mean in a bash script?
- 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 do I convert this for loop into a while loop?
- 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
- source command not found in sh shell
- Array to Hash Ruby
- Printing from a declared array in MIPS
- Print array elements on separate lines in Bash?
- Java says this method has a constructor name
- Difference between sh and Bash
- 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
- numpy: Invalid value encountered in true_divide
- ValueError: all the input arrays must have same number of dimensions
- Shell: How to call one shell script from another shell script?
- Java Comparator class to sort arrays
- Convert char array to a int number in C
- Block Comments in a Shell Script