I have two arrays, which I want to print out in two separate columns from a single printf
call. The following:
printf "%-${padding}s→ %s\n" "${lnFrom[@]}" "${lnTo[@]}"
Outputs:
dotfiles/git/gitconfig → dotfiles/hyper/hyper.css
dotfiles/hyper/hyper.js → dotfiles/nvim/nvimrc
dotfiles/nvim/warm_nature.vim → dotfiles/zsh/zshrc
~/.gitconfig → ~/.hyper.css
~/.hyper.js → ~/.nvimrc
~/.vim/colors/warm_nature.vim → ~/.zshrc
The three first lines are represent the lnFrom
array, and the three last lnTo
, they should be on their respective columns.
(padding
in the printf statement is just a variable containing the length of the longtest string in lnFrom
array)
Thoughts on how to fix this while keeping the single printf call? (not introducing any loops)