linux查看bash pro,Pro Bash Programming : Scripting the GNU/Linux Shell

本文章重点介绍了参数扩展和数组在Shell编程中的重要性和使用方法。详细探讨了由Korn Shell引入并被纳入标准Unix shell的参数扩展特性,这些特性赋予了POSIX shell强大的功能。同时,虽然数组不是POSIX标准的一部分,但它们极大地增强了shell的功能,使其能够以逻辑单位收集数据。此外,文章还讨论了变量作用域的理解如何避免许多常见错误,并强调了合理命名变量的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Chapter 5 Summary

By far the largest subject in this chapter is parameter expansion, and by far the largest section of parameter expansion is devoted to those expansions that were introduced by the KornShell and incorporated into the standard Unix shell. These are tools that give the POSIX shell much of its power. The examples given in this chapter are relatively simple; the full potential of parameter expansion will be shown as you develop serious programs later in the book.

Next in importance are arrays. Though not part of the POSIX standard, they add a great deal of functionality to the shell by making it possible to collect data in logical units.

Understanding the scope of variables can save a lot of head scratching, and well-named variables make a program more understandable and maintainable.

Manipulating the positional parameters is a minor but important aspect of shell programming, and the examples given in this chapter will be revisited and expanded upon later in the book.

Commands

declare: Declares variables and sets their attributes

eval: Expands arguments and executes the resulting command

export: Places variables into the environment so that they are available to child processes

shift: Deletes and renumbers positional parameters

shopt: Sets shell options

unset: Removes a variable entirely

Concepts

Environment: A collection of variables inherited from the calling program and passed to child processes

Array variables: Variables that contain more than one value and accessed using a subscript

Scalar variables: Variables that contain a single value

Associative arrays: Array variables whose subscript is a string rather than an integer

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值