Created
March 30, 2018 08:29
-
-
Save Da-Juan/45f68b4edf918d74bb0c6b14afb2ba53 to your computer and use it in GitHub Desktop.
Order page numbers to print in booklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
n=$1 | |
j=0 | |
pages="" | |
for i in $(seq 1 $(( n / 2))); do | |
if [ $((i%2)) -ne 0 ]; then | |
if [[ $pages != '' ]]; then | |
pages=$pages',' | |
fi | |
pages=$pages$(( n - j ))','$i | |
else | |
if [[ $pages != '' ]]; then | |
pages=$pages',' | |
fi | |
pages=$pages$i','$(( n - j )) | |
fi | |
(( j++ )) | |
done | |
echo "$pages" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment