Skip to content

Instantly share code, notes, and snippets.

@mather
Last active March 20, 2018 09:40
Show Gist options
  • Select an option

  • Save mather/25a52227052951e49689a764645acd35 to your computer and use it in GitHub Desktop.

Select an option

Save mather/25a52227052951e49689a764645acd35 to your computer and use it in GitHub Desktop.
引数を反転させる関数(イマイチ)
#!/bin/bash
set -e
reverse () {
local COUNT
COUNT=$#
local PARAMS
PARAMS=("$@")
for i in $(seq $(($COUNT - 1)) 0)
do
echo ${PARAMS[${i}]}
done
}
AR=(1 2 3)
RES=($(reverse ${AR[@]}))
echo ${RES[@]}
# => 3 2 1
@mather
Copy link
Copy Markdown
Author

mather commented Mar 20, 2018

本当は tac が使いたい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment