Home > OS >  A few questions ask Shell script
A few questions ask Shell script

Time:09-27

1. The following results:

[liuqiang @ slaves1 ~] $aaaa=BBBB
[liuqiang @ slaves1 ~] $env | grep aaaa
[liuqiang @ slaves1 ~] $set | grep aaaa
Aaaa=BBBB
[liuqiang @ slaves1 ~] $export aaaa
[liuqiang @ slaves1 ~] $env | grep aaaa
Aaaa=BBBB
[liuqiang @ slaves1 ~] $unset aaaa
[liuqiang @ slaves1 ~] $set | grep aaaa
_=aaaa //here is how to return a responsibility excuse me?
[liuqiang @ slaves1 ~] $set | grep aaaa

2. The following the results
[liuqiang @ node4 ~] $test='* means all files' //
[liuqiang @ node4 ~] $echo $test
1. TXT iostat. Sh test test1 means all files
[liuqiang @ node4 ~] $test="*" means all files //use double quotes
[liuqiang @ node4 ~] $echo $test
1. TXT iostat. Sh test test1 means all files

Excuse me: variable definition, at the time of reference, as before the variable is stored using single quotes or double quotes are no difference, are the direct reference variables, ask others to explain was a shell variable storage is not stored quotes, is not very understanding,,,


2. [-d $1] this conditional expression, want to know where to input the parameters of the $1 from?
It feels like no input parameter list ~

Above, thank `

CodePudding user response:

1, I don't know much about it, probably waiting for redefining variables mean
2, single and double quotes are for the convenience of the long variable definition with a space, such as test=Hello world is not enough, must be enclosed in quotation marks the test='Hello world'; And the effect of double quotation marks can be reference variables, such as define test1='$test! Welcome last come to ', echo $test1 output is $test! Welcome last come to define test2="$test! Welcome last come to ", echo $test2 output is Hello world! Welcome last come to,
3, $1 in general is script followed by the first parameter, such as./test. Sh, 123 $1=123 in a script,

CodePudding user response:

Single and double quotes are mainly is to distinguish between output reference variables, or the value of the
$echo $PATH ", "
/sbin,/usr/local/sbin,/usr/local/bin:/usr/sbin,/usr/bin,/sbin,/bin:/usr/games:/usr/local/games:/snap/bin
$echo '$PATH'
$PATH

CodePudding user response:

No one knows? Have a better interpretation?
  • Related