Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the unset command in Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the unset command in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Linux common commands unset commands are mainly used to delete specified shell variables or functions.

Unset deletes the specified shell variable or function.

Summary unset [- f] [- v] [- n] [name...] The main purpose is to delete one or more shell variables (excluding read-only variables).

Delete one or more shell functions.

Delete one or more variables with reference attributes (if the-n option exists).

Option-f: only delete functions. -v: delete only variables (excluding read-only variables). -n: deletes the variable name with the reference property (if this option exists). Parameter name (optional): the variable or function to delete.

The return value returns success unless the option is incorrect or the variable or function to be deleted has a read-only property.

Example # delete a variable. Declare paper_size='B5' unset-v paper_size # removes the function. Function show_result () {echo 'Last Command Return: $?';} unset-f show_result # when no option is specified, delete the variable first, and delete the function if it fails. Declare-I aa=100 function aa () {echo 'aa';} unset aa # variable' aa' has been deleted. Declare-p aa # function 'aa' exists. Declare-F | grep aa # demonstrates that unset uses the-n option, and name specifies what happens when referencing variables. Declare adept 3 # defines the reference variable declare-n Benza # View properties, displays declare-n b = "a" declare-p b # shows 3 echo ${b} # shows an echo ${! b} # specifies the-n option unset-n b # reference variable b has been deleted declare-p b # referenced variable a has not been deleted declare-p a # demonstrates that unset does not use the-n option, and name specifies what happens when the variable is referenced. Declare aquire3 # defines the reference variable declare-n Benza # View properties, displays declare-n b = "a" declare-p b # shows 3 echo ${b} # shows an echo ${b} # shows that unset b # reference variable b is not deleted when the-n option is not specified, shows that declare-n b = "a" declare-p b # referenced variable an is deleted declare-p a note that the command is a built-in command for bash See the help command for help.

The above is all the contents of the article "how to use unset commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report