I am trying to make sh script which uses 'sed' to make bubblesort algorithmI am strugling, how to make for loopfor n in $1do   echo $ndoneHow can I change body of the for loop to make just n-1 cycles? I tried this $1-1 but it doesn't work. It will print part of the string and - 1.
How to make for loop with $1 - 1 cycles
sed;for
n-1 cycles means that the last item shouldn't be considered. Use the following approach(assuming that your input argument will always be a string of space-delimited substrings):s=$1for n in ${s:0:-2}do     echo $n done${s:0:-2} - slice of items containing all items except the last one    ^  ^    |  |   from to