返回总目录页

unset命令详解

  

基础命令学习目录首页

 

功能说明: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
版权声明:本文为博主原创文章,转载请附上博文链接!

 

posted @   马昌伟  阅读(1415)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
博主链接地址:https://www.cnblogs.com/machangwei-8/
点击右上角即可分享
微信分享提示