當前位置:首頁 » 操作系統 » linuxsh

linuxsh

發布時間: 2022-01-10 08:09:00

linux 命令中的sh是什麼意思

1、sh是linux中運行shell的命令,是shell的解釋器,shell腳本是linux中殼層與命令行界面,用戶可以在shell腳本輸入命令來執行各種各樣的任務。

要運行shell腳本,首選需要給shell腳本許可權,這里里以hello.sh文件為例,首先需要按下「crtl+shift+T」打開終端窗口:

Ⅱ Linux 腳本 sh 和 ./ 的區別

區別只有一點:

sh表示腳本默認使用sh腳本解釋器。

未指定腳本解釋器默認為 ./。

具體解釋:

使用「./」執行腳本,對應的xxx.sh腳本必須要有執行許可權。

使用「sh」 執行腳本,對應的xxx.sh沒有執行許可權,亦可執行。

當腳本開頭使用#!設置使用的shell類型時,使用「./」執行腳本時,則使用「#!」標志的shell執行腳本;若無使用「#!」標記,則使用系統設置的默認shell執行腳本。

(2)linuxsh擴展閱讀:

舉例:

登錄用戶root查看許可權:

-rwx—— 1 root root

執行這個shell腳本 :

./test 成功。

sh test 成功。

去掉執行許可權x:

-rw——- 1 root root 17 2011-09-22 23:33 test

執行這個shell腳本。

./test 失敗 (-bash: ./test: Permission denied)。

sh test 成功。

Ⅲ Linux shell 腳本中, $@ 和$# 分別是什麼意思

直接看示例:
[root@localhost xly]# cat t.sh
#!/bin/bash
echo $#
echo $@
[root@localhost xly]# sh t.sh
0
[root@localhost xly]# sh t.sh a b c
3
a b c
說明:
$@表示所有參數
$#表示所有參數的個數

Ⅳ linux ./a.sh 命令 與sh a.sh的區別是什麼

linux ./a.sh 命令 與sh a.sh的區別為:可執行屬性不同、執行方式不同、兼容性不同。

一、可執行屬性不同

1、./a.sh 命令:./a.sh 命令的文件必須具有可執行屬性。

2、sh a.sh命令:sh a.sh命令的文件不必具有可執行屬性。

二、執行方式不同

1、./a.sh 命令:./a.sh 命令使用腳本中第一行所指定的命令來解釋和執行文件。

2、sh a.sh命令:sh a.sh命令使用shell工具的SH腳本直接解釋和執行文件。

三、兼容性不同

1、./a.sh 命令:./a.sh 命令的兼容性比sh a.sh命令更好,不受限於shell工具。

2、sh a.sh命令:sh a.sh命令的兼容性比./a.sh 命令更差,受限於shell工具。

Ⅳ Linux下面如何運行 SH文件

本文介紹Linux下面用命令如何運行.sh文件的方法,有兩種方法:

一、直接./加上文件名.sh,如運行hello.sh為./hello.sh【hello.sh必須有x許可權】

二、直接sh 加上文件名.sh,如運行hello.sh為sh hello.sh【hello.sh可以沒有x許可權】

工具/原料

  • windows、linux

  • xshell

  • 方法一:當前目錄執行.sh文件

  • 1

    【步驟一】cd到.sh文件所在目錄

    比如以hello.sh文件為例,如下圖

  • 注意事項

  • 用「./」加文件名.sh執行時,必須給.sh文件加x執行許可權

  • 如果對您有幫助,幫忙點「有得」,有助於您是我們進步的最大動力!

  • 如果您喜歡,請點「投票」,您的參與是我們進步的最大動力!

  • 如果您有疑問,請提交疑問,與您的互動是我們進步的最大動力!

  • 僅供參考

Ⅵ 怎麼創建.sh 文件(linux)

創建方法如下:

1、touch hello.sh

2、vim hello.sh

鍵入i

插入#!/bin/sh

echo hello world;

鍵入:

esc

:

wq

3、chmod 700 hello.sh

4.、執行./hello.sh

(6)linuxsh擴展閱讀:

關於linux shell 文件的操作總結

1、創建文件夾

#!/bin/sh

mkdir -m 777 "%%1"

2、創建文件

#!/bin/sh

touch "%%1"

3、刪除文件

#!/bin/sh

rm -if "%%1"

4、刪除文件夾

#!/bin/sh

rm -rf "%%1"

5、刪除一個目錄下所有的文件夾

#!/bin/bash

direc="%%1" #$(pwd)

for dir2del in $direc/* ; do

if [ -d $dir2del ]; then

rm -rf $dir2del
fi
done

6、清空文件夾

#!/bin/bash

direc="%%1" #$(pwd)

rm -if $direc/*

for dir2del in $direc/* ; do

if [ -d $dir2del ]; then

rm -rf $dir2del

fi

done

7、讀取文件

#!/bin/sh

Ⅶ 請問linux系統下,sh命令是做什麼工作的

sh或是執行腳本,或是切換到sh這個bash里,默認的shell是bash,你可以試試tcsh啊,csh啊,ksh,zsh什麼的,看看別的shell是什麼樣子的。當然,linux中sh是鏈接到bash上的,所以sh與bash在功能上是沒有區別的。
還有就是在執行腳本的時候是用sh
+
腳本名的方式來執行,其實,大部分的時候,簡單腳本只要許可權設置正確,可以直接執行,不需要sh命令的

Ⅷ Linux shell #* 是什麼意思

這是 變數擴展表達式。
"#* " 是指從變數host中刪除空格前面的所有字元
一下摘取自 bash manual

${parameter#word}
${parameter##word}
The word is expanded to proce a pattern just as in filename expansion (see section 3.5.8 Filename Expansion). If the pattern matches the beginning of the expanded value of parameter, then the result of the expansion is the expanded value of parameter with the shortest matching pattern (the `#' case) or the longest matching pattern (the `##' case) deleted. If parameter is `@' or `*', the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with `@' or `*', the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list.
${parameter%word}
${parameter%%word}
The word is expanded to proce a pattern just as in filename expansion. If the pattern matches a trailing portion of the expanded value of parameter, then the result of the expansion is the value of parameter with the shortest matching pattern (the `%' case) or the longest matching pattern (the `%%' case) deleted. If parameter is `@' or `*', the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with `@' or `*', the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list.
${parameter/pattern/string}
${parameter//pattern/string}

The pattern is expanded to proce a pattern just as in filename expansion. Parameter is expanded and the longest match of pattern against its value is replaced with string. In the first form, only the first match is replaced. The second form causes all matches of pattern to be replaced with string. If patternbegins with `#', it must match at the beginning of the expanded value of parameter. If pattern begins with `%', it must match at the end of the expanded value of parameter. If string is null, matches of pattern are deleted and the / following pattern may be omitted. If parameter is `@' or `*', the substitution operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with `@' or `*', the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.

${parameter:-word}
If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.
${parameter:=word}
If parameter is unset or null, the expansion of word is assigned to parameter. The value of parameter is then substituted. Positional parameters and special parameters may not be assigned to in this way.
${parameter:?word}
If parameter is null or unset, the expansion of word (or a message to that effect if word is not present) is written to the standard error and the shell, if it is not interactive, exits. Otherwise, the value of parameter is substituted.
${parameter:+word}
If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted.
${parameter:offset}
${parameter:offset:length}
Expands to up to length characters of parameter starting at the character specified by offset. If length is omitted, expands to the substring of parameter starting at the character specified by offset. length and offset are arithmetic expressions (see section 6.5 Shell Arithmetic). This is referred to as Substring Expansion.

length must evaluate to a number greater than or equal to zero. If offset evaluates to a number less than zero, the value is used as an offset from the end of the value of parameter. If parameter is `@', the result is length positional parameters beginning at offset. If parameter is an array name indexed by `@' or`*', the result is the length members of the array beginning with ${parameter[offset]}. Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1.
${!prefix*}
Expands to the names of variables whose names begin with prefix, separated by the first character of the IFS special variable.
${#parameter}
The length in characters of the expanded value of parameter is substituted. If parameter is `*' or `@', the value substituted is the number of positional parameters. If parameter is an array name subscripted by `*' or `@', the value substituted is the number of elements in the array.

Ⅸ linux shell 中&>是什麼意思

& 後台執行
> 輸出到
不過聯合使用也有其他意思,比如nohup輸出重定向上的應用
例子:nohup abc.sh > nohup.log 2>&1 &
其中2>&1 指將STDERR重定向到前面標准輸出定向到的同名文件中,即&1就是nohup.log

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:764
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:663
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:310
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:288
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:816
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:161
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:93
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:506
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:657
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:480