-2

I want to create a 2 columns like:

1 10
1 20 
1 30
1 40
1 50
2 10
2 20
2 30 
2 40
2 50
3 10
3 20
3 30
3 40
3 50

any suggestion please?

4
  • @StephenHarris for first column I tried this: for i in {1..5}; do echo "1"; done but I have to repeat this 3 time. I am looking for a less time-consuming solution
    – zara
    Aug 18, 2016 at 19:04
  • -1 Because of lack of research effort.
    – wjandrea
    Aug 18, 2016 at 19:30
  • @wjandrea I am in learning process. I do not understand what was wrong by this question, while it was really useful for me
    – zara
    Aug 18, 2016 at 19:35
  • @zara On StackExchange sites, you're expected to do your own research before turning to the community, and then to demonstrate the research you've done. I think you could have come up with an answer to this question if you had done some reading.
    – wjandrea
    Aug 18, 2016 at 19:56

3 Answers 3

6

With modern shells you can combine brace expansions and run stuff like:

printf %s\\n ID_{1..3}' '{10..50..10}
0
4

If you have a recent version of Bash:

for i in {1..3}; do
    for j in {10..50..10}; do
        echo "$i $j"
    done
done

If you have an older version:

for i in {1..3}; do
    for j in {1..5}; do
        echo "$i ${j}0"
    done
done

Or, using seq:

for i in $(seq 1 3); do
    for j in $(seq 10 10 50); do
        echo "$i $j"
    done
done
1

A variation of don_crissti's answer which just recognises the fact that the zero at the end is constant:

$ printf '%s\n' {1..3}' '{1..5}0
1 10
1 20
1 30
1 40
1 50
2 10
2 20
2 30
2 40
2 50
3 10
3 20
3 30
3 40
3 50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .