It is kind of hard to guess at how to change your program to write its output in the order you want if you don't show us the code that is writing output in snake order... Show us your code!
#!/bin/bash
#program for columnar transposition
#file from previous question (a)
file="encrypted.txt"
#remove all the spaces and newline and put it on a new file
name=$(cat $file)
echo $name | tr -d ' ' > temp.txt
file4="temp.txt"
name4=$(cat $file4)
echo $name4 | sed 's/\(.\)/\1\n/g' > file4.txt
echo "enter how many cols:"
read cols
IFS=$'\n' a=($(cat file4.txt))
for j in $(seq ${#a[*]}); do
[[ ${a[$j-1]} = $name ]] && echo "${a[$i]}"
done
for (( i=0; i<=$(( ${#a[@]} / cols )); ++i )); do
for (( j=0; j<cols; ++j )); do
if (( i%2 )); then idx=$(( (i + 1) / 2 * 2 * cols - j - 1 ))
else idx=$(( (i / 2) * 2 * cols + j )); fi
printf "%-4s " "${a[idx]}"
done
printf "\n"
done
---------- Post updated at 05:17 PM ---------- Previous update was at 05:14 PM ----------
the output is all ok and correct.
now i dont know how to put all the output into 1 single string.
like i said, i googled it and found how to combine all but not with any kind of sorting