#!/bin/bash
# program: lists big planets
for planet in "Mercury 36" "Venus 67" "Earth 93" "Mars 142" "jupiter 483"
do
set -- $planet
echo "$1 $2,000,000 miles from the sun."
done
# program: lists big planets
for planet in "Mercury 36" "Venus 67" "Earth 93" "Mars 142" "jupiter 483"
do
set -- $planet
echo "$1 $2,000,000 miles from the sun."
done
这里“set -- $planet”重新指定了命令行参数。将planet的内容作为命令行参数。
而且这里planet是每个双引号括起来的字符串而不是像
for planet in "Mercury Venus Earth Mars Jupiter"