We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cfee4f3 commit 5af3298Copy full SHA for 5af3298
book.org
@@ -196,9 +196,23 @@
196
#+begin_src bash
197
a=(a b c d e f g)
198
echo "${a[@]:1}" # tail of array
199
- echo "${a[@]:1:2}" # from position 1, take 2 elements
+ echo "${a[@]:1:2}" # from that, take 2 elements
200
#+end_src
201
202
+ Don't ask me why, but when the array is =$@=, it seems that it
203
+ behaves a bit differently (would be great to know why):
204
+
205
+ #+begin_src bash
206
+ a=(a b c d e f g)
207
+ foo() {
208
+ echo "${@:2}" # tail of array
209
+ echo "${@:2:2}" # from that, take 2 elements
210
+ }
211
+ foo a b c d
212
+ foo "${a[@]}"
213
+ #+end_src
214
215
216
** Read lines from file
217
The =read= command we used just above is part of the usual idiom to
218
read a file line by line.
0 commit comments