unset命令詳解

  

基礎命令學習目錄首頁html

 

功能說明:unset是一個內建的Unix
shell命令,在Bourne shell家族(sh、ksh、bash等)和C shell家族(csh、tcsh等)都有實現。它能夠取消設置一個shell變量,從內存和shell的導出環境中刪除它。它實現爲一個殼層內建指令,由於它直接操縱shell的內部。
只讀shell變量不能被unset。若是試圖unset只讀變量,unset命令將打印一個錯誤消息,並返回一個非零的退出代碼。
This command removes one or more variables. Each name is a variable name, specified in any of the ways acceptable to the
set command. If a name refers to an element of an array then that element is removed without affecting the rest of the array. If a
name consists of an array name with no parenthesized index, then the entire array is deleted. The
unset command returns an empty string as result. An error occurs if any of the variables doesn't exist, and any variables after the non-existent one are not deleted.
語  法:
unset [-fv][變量或函數名稱]補充說明:unset爲shell內建指令,可刪除變量或函數。參   數:
  -f  僅刪除函數。
  -v  僅刪除變量。
[3][root][test:/home/root/Desktop] set lx = "ls -lh" [3][root][test:/home/root/Desktop] $lx total 80K drwxrwxr-x  2 root tt 4.0K 2014-02-19 09:32 bin drwxrwxr-x  3 root tt 4.0K 2014-02-10 10:56 Data drwxrwxr-x  2 root tt 4.0K 2014-02-19 09:32 lib drwxrwxr-x 10 root tt 4.0K 2014-02-20 16:12 script -r--r--r--  1 root tt  312 2014-02-19 09:32 sut.cs [3][root][test:/home/root/Desktop] [3][root][test:/home/root/Desktop] [3][root][test:/home/root/Desktop] set ......此處省略輸出 [3][root][test:/home/root/Desktop] set |grep -i lx lx ls -lh [3][root][test:/home/root/Desktop] [3][root][test:/home/root/Desktop] unset lx [3][root][test:/home/root/Desktop] set | grep -i lx --------------------- 做者:惹不起的程咬金 來源:CSDN 原文:https://blog.csdn.net/carolzhang8406/article/details/21246145 版權聲明:本文爲博主原創文章,轉載請附上博文連接!
相關文章
相關標籤/搜索