-n在Bash中是什么意思 [英] What does -n mean in Bash

查看:1079
本文介绍了-n在Bash中是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常愚蠢的问题,但是...如果[! -n"$ 1"]的意思是,如果不超过1个参数,则......这样我就能知道它是如何工作的,但是-n是数字的缩写吗? 我一直在阅读《高级bash编程指南》,他们只是开始使用它,我试图找到它,并提出它必须是内置"默认参数,第二个问题是是否有一个命令来显示默认值参数在Linux中.

This is probably a really dumb question, but... if [ ! -n "$1" ], means, if not more than 1 argument do... so I get how it works but what is -n is it the abbreviation of number? I've been reading through The Advanced bash programming guide and they just start using it, I've tried to find it and come up with it must be a "built-in" default parameter, second question is there a command to show default parameter's in Linux.

推荐答案

test(又名[)的-n参数表示不为空".您发布的示例的意思是如果$1不为空.这是说[ -z "$1" ];($1为空)的一种a回方式.

The -n argument to test (aka [) means "is not empty". The example you posted means "if $1 is not not empty. It's a roundabout way of saying [ -z "$1" ]; ($1 is empty).

您可以通过help test了解更多信息.

You can learn more with help test.

$1和其他($2$3 ..)是位置参数.它们就是作为参数传递给您所在的脚本或函数的内容.例如,将名为foo的脚本作为./foo bar baz运行将导致$1 == bar$2 == baz

$1 and others ($2, $3..) are positional parameters. They're what was passed as arguments to the script or function you're in. For example, running a script named foo as ./foo bar baz would result in $1 == bar, $2 == baz

这篇关于-n在Bash中是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆