Redian新闻
>
大虾,看看这是咋回子事尼!
avatar
大虾,看看这是咋回子事尼!# Unix - 噫吁兮,危乎高哉
t*l
1
# who
john pts/3 Sep 2 11:11 (903980497497)
# echo $argv[1]
Subscript out of range
what is wrong?
avatar
o*z
2

1太大就换$argv[0]嘛
实在不行man echo

【在 t*******l 的大作中提到】
: # who
: john pts/3 Sep 2 11:11 (903980497497)
: # echo $argv[1]
: Subscript out of range
: what is wrong?

avatar
t*l
3
echo $argv[0] returns nothing !
pls help more!
avatar
o*z
4
what do you want?

【在 t*******l 的大作中提到】
: echo $argv[0] returns nothing !
: pls help more!

avatar
t*l
5
# who
jane pts/4 Sep 2 2:30 (oweoiutoiuywroitu)
I want it echo the user name "jane", so I use the following :
# echo $argv[1]
error
# echo $argv[0]
#
nothing returned.
avatar
r*a
6
对您的佩服如滔滔江水。。。。。。。

【在 t*******l 的大作中提到】
: # who
: jane pts/4 Sep 2 2:30 (oweoiutoiuywroitu)
: I want it echo the user name "jane", so I use the following :
: # echo $argv[1]
: error
: # echo $argv[0]
: #
: nothing returned.

avatar
o*z
7
or try
who -q | grep -v "^#"

【在 t*******l 的大作中提到】
: # who
: jane pts/4 Sep 2 2:30 (oweoiutoiuywroitu)
: I want it echo the user name "jane", so I use the following :
: # echo $argv[1]
: error
: # echo $argv[0]
: #
: nothing returned.

avatar
t*l
8
don't say so...
I am a beginner of unix.

【在 r**a 的大作中提到】
: 对您的佩服如滔滔江水。。。。。。。
avatar
t*l
9
perfect!
thanks for teaching !

【在 o***z 的大作中提到】
: or try
: who -q | grep -v "^#"

avatar
r*a
10
不如用whoami算了
那个grep -v "^#" 屁用没有,hoho!

【在 o***z 的大作中提到】
: or try
: who -q | grep -v "^#"

avatar
t*l
11
but I learn about grep -v "^#" at the same time! :))))
it is useful to me.
also , I learn "whoami" this time too!
also great!
avatar
r*a
12
hoho! Good luck lah!

【在 t*******l 的大作中提到】
: but I learn about grep -v "^#" at the same time! :))))
: it is useful to me.
: also , I learn "whoami" this time too!
: also great!

avatar
r*a
13
if u insist to use echo, then:
echo `whoami`

【在 t*******l 的大作中提到】
: but I learn about grep -v "^#" at the same time! :))))
: it is useful to me.
: also , I learn "whoami" this time too!
: also great!

avatar
t*l
14
great.
see, unix is so versatile, so flexible.
that is why I LOVE IT!
I have to learn it, try to be perfect!
avatar
t*l
15
but I still want to know why echo $argv[1] and echo $argv[0] doesn't work.

【在 r**a 的大作中提到】
: if u insist to use echo, then:
: echo `whoami`

avatar
r*a
16
因为你在shell里面调用$argv[0],这个$argv[0]就应该是shell被调用时传入的第一个
参数,但是你的shell在初始化时根本没有输入参数。另外,脚本变元应该是$0、$1的
格式。

【在 t*******l 的大作中提到】
: but I still want to know why echo $argv[1] and echo $argv[0] doesn't work.
avatar
d*i
17
try
who | awk '{print $1}'

【在 t*******l 的大作中提到】
: # who
: jane pts/4 Sep 2 2:30 (oweoiutoiuywroitu)
: I want it echo the user name "jane", so I use the following :
: # echo $argv[1]
: error
: # echo $argv[0]
: #
: nothing returned.

avatar
t*l
18
right,this works perfectly.
thanks.

【在 d****i 的大作中提到】
: try
: who | awk '{print $1}'

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。