I have the script below that prints on the screen the even numbers from 1 to the input argument.
#!/bin/bash
for i in $(seq 1 ($1)); do
if [ $(($i % 2)) -eq 0 ]
then
echo "$i \c"
fi
done
For example, to script the script with argument 10 the script prints the following
2 4 6 8 10
I would like the script to print only up to the value of the entry minus 1. That is, $1-1
which for this case is 9
.
I have tried the following modification without success.
for i in $(seq 1 (( $1 - 1 )) ); do
if [ $(($i % 2)) -eq 0 ]
then
echo "$i \c"
fi
done