i need help
Am written a script to solve my manual labor of cloning in my environment
i want to use for statement to give me this kind of output
Script
for i in 0-4 && j in a b c d e
do
echo " $i $j
this is what i want to achieve
output
0a
1b
2c
3d
4e
PLEASE I DON’T KNOW HOW TO PUT THIS SCRIPT TOGETHER TO HAVE THE OUTPUT ABOVE

Recommended Answers

All 2 Replies

paste -d' ' <(seq 0 4) <(tr ' ' '\n' <<< "a b c d e")

paste joins lines of a file according to some delimeter.
The funky <(...) syntax is bash Process Substitution which allows you to use a named pipe as if it were a file.
The <<< is another nicety that allows you to 'redirect' a string to a programs stdin. (analagous to something like echo "a b c d e" | ...)

Use nested loops:

`

for i in {0..4} ## you may need $(seq 4)
do
  for j in {a..e}  ## or: for j in a b c d e
  do
    printf "%s%s\n" "$i" "$j"
  done
done

`

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.