当前位置:首页 » 操作系统 » linuxshell返回值

linuxshell返回值

发布时间: 2022-07-30 08:50:40

linuxshell中怎么接收可执行程序的返回值

程序执行后就会产生返回值,你可以通过重定向到文本,或者通过管道符把他放到下一个命令的参数中

㈡ linux shell函数返回值的问题

yes_or_no "$1"
temp=$?

㈢ linux 的shell怎么得到函数返回值

函数的返回值实际上就是函数的退出状态
yes_or_no Kitty
i=$?
就可以了。
$? 代表上一条指令的退出状态。
怎样使用if语句就随便你了。

㈣ linux shell ssh wc-l返回值,无法参与判断

可能的原因:

  1. 语法错误,if中的表达式与两个中括号之间要有空格;

  2. 需要将$result加双引号,即if [ "$result" -eq "0" ]; then ....

㈤ linux shell中如何接收程序返回值

$?
$?就是表示上一次脚本或者命令退出时的返回值。通常,0代表成功;非0代表出现错误。
类似的一些符号如$0 $1 $2 $@ $# 。

Before we move on, there is a perversity about tests in Bash shells that I want to discuss. It turns out, because of a historical accident that now might as well be cast in concrete, when a test is concted or a command returns a result value, the numerical value for "true" is 0, and "false" is 1. Those of you who have some programming experience will likely find this reversal of intuition as annoying as I do.

Here is a way to get the result of the most recent logical test (and to show the weird reversal described above):

$ test -e .
$ echo $?
0

$ test -e xyz
$ echo $?
1

㈥ linux shell中获得进程返回值

se
"$x"
in
y
|
yes
)
return
0;;
n
|
no
)
return
1;;
*
)
echo
"Answer
yes
or
no"
shell结束用return跳出while
true
while
true
是一直为真,不断循环,直到输入yes或no时,用return退出shell程序。程序结束了,循序肯定也结束了。
-------------------------
补充:也就是说while
true
实际是一个死循环。我可以这样理解么?我们是用return
返回0或1来退出循环。能把代码运行步骤说一下么。输入三个数据分别是yes,no.和其他任意的。
可以说是死循环。不是说所有的死循环都不好,这里的死循环保证了程序一直运行,直到得到你想要的结果。
输入yes,返回0,就是正常结束
输入no,返回1,就是异常结束
输入其它的,则进行下一轮循环,要求你重新输入

㈦ linux shell关于返回值

case "$x" in
y | yes ) return 0;;
n | no ) return 1;;
* ) echo "Answer yes or no"
shell结束用return跳出while true

while true 是一直为真,不断循环,直到输入yes或no时,用return退出shell程序。程序结束了,循序肯定也结束了。

-------------------------
补充:也就是说while true 实际是一个死循环。我可以这样理解么?我们是用return 返回0或1来退出循环。能把代码运行步骤说一下么。输入三个数据分别是yes,no.和其他任意的。

可以说是死循环。不是说所有的死循环都不好,这里的死循环保证了程序一直运行,直到得到你想要的结果。
输入yes,返回0,就是正常结束
输入no,返回1,就是异常结束
输入其它的,则进行下一轮循环,要求你重新输入

㈧ linux中shell编程中的return在里面有什么作用

1、终止一个函数.
2、return命令允许带一个整型参数, 这个整数将作为函数的"退出状态
码"返回给调用这个函数的脚本, 并且这个整数也被赋值给变量$?.
3、命令格式:return value

热点内容
linuxc函数库 发布:2025-03-16 22:03:33 浏览:921
iphone最新版系统从哪里改密码 发布:2025-03-16 21:56:19 浏览:596
python的execute 发布:2025-03-16 21:40:24 浏览:767
今天的访问量就靠你了 发布:2025-03-16 21:39:35 浏览:430
linux分区表查看 发布:2025-03-16 21:20:17 浏览:645
java多个if 发布:2025-03-16 21:15:46 浏览:696
可乐存储 发布:2025-03-16 21:15:07 浏览:873
ios迁移安卓用什么助手 发布:2025-03-16 20:12:42 浏览:720
python异常值处理 发布:2025-03-16 20:12:42 浏览:581
POtn编程 发布:2025-03-16 20:06:11 浏览:776