- Bash Cookbook
- Ron Brash Ganesh Naik
- 115字
- 2021-07-23 19:17:32
Getting program input parameters
Retrieving program input parameters or arguments is very similar to function parameters at the most basic level. They can be accessed in the same fashion as $1 (arg1), $2 (arg2), $3 (arg3), and so on. However, so far, we have seen a concept called flags, which allows you to perform neat things such as-l, --long-version, -v 10, --verbosity=10. Flags are effectively a user-friendly way to pass parameters or arguments to a program at runtime. For example:
bash myProgram.sh -v 99 --name=Ron -l Brash
Now that you know what flags are and how they can be helpful to improve your script, use the following section as a template.
推薦閱讀
- 程序員修煉之道:程序設計入門30講
- Mastering Articulate Storyline
- NativeScript for Angular Mobile Development
- Visual C++串口通信技術詳解(第2版)
- TypeScript圖形渲染實戰:基于WebGL的3D架構與實現
- CKA/CKAD應試教程:從Docker到Kubernetes完全攻略
- Building Serverless Applications with Python
- Android群英傳
- Python Data Science Cookbook
- Processing創意編程指南
- Mastering Python Design Patterns
- Orleans:構建高性能分布式Actor服務
- Android技術內幕(系統卷)
- Mastering Machine Learning with R
- Python程序設計教程