echo输出的几个例子
-
// ch1 project main.go
-
package main
-
-
import (
-
"fmt"
-
"os"
-
"strings"
-
)
-
-
func main() {
-
s := strings.Join(os.Args, " ")
-
fmt.Println("s=", s)
-
fmt.Println(strings.Join(os.Args, " "))
-
}
结果输出:
[root@hadoop1 ch1]# ./echo hello world It is very good
s= ./echo hello world It is very good
./echo hello world It is very good
[root@hadoop1 ch1]#
-------------------------------------------------------------
-
// ch1 project main.go
-
package main
-
-
import (
-
"fmt"
-
"os"
-
)
-
-
func main() {
-
for key, val := range os.Args {
-
fmt.Printf("%v: %s\n", key, val)
-
}
-
}
输出结果:
[root@hadoop1 ch1]# ./echo hello world It is very good
0: ./echo
1: hello
2: world
3: It
4: is
5: very
6: good
[root@hadoop1 ch1]#
阅读(601) | 评论(0) | 转发(0) |