Skip to main content
Question Protected by dr_
Tweeted twitter.com/StackUnix/status/945174893854908417
deleted 65 characters in body
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

may I dare to just through in a quite basic question again,
isIs there a simple way to reverse an array?

#!/bin/bash

array=(1 2 3 4 5 6 7)

echo "${array[@]}"

so I would get: 7 6 5 4 3 2 1
instead of: 1 2 3 4 5 6 7

may I dare to just through in a quite basic question again,
is there a simple way to reverse an array?

#!/bin/bash

array=(1 2 3 4 5 6 7)

echo "${array[@]}"

so I would get: 7 6 5 4 3 2 1
instead of: 1 2 3 4 5 6 7

Is there a simple way to reverse an array?

#!/bin/bash

array=(1 2 3 4 5 6 7)

echo "${array[@]}"

so I would get: 7 6 5 4 3 2 1
instead of: 1 2 3 4 5 6 7

Source Link
nath
  • 6.1k
  • 13
  • 51
  • 94

Bash - reverse an array

may I dare to just through in a quite basic question again,
is there a simple way to reverse an array?

#!/bin/bash

array=(1 2 3 4 5 6 7)

echo "${array[@]}"

so I would get: 7 6 5 4 3 2 1
instead of: 1 2 3 4 5 6 7