bash 4.0 – new feature mapfile
Recently I encountered a problem where I had to create couple of arrays in bash and these were quite dynamic in nature. This script was supposed to be used by couple of guys whom I did not trust too much in opening the script and modifyikng the array. So, the solution was to put these in different files and then put them in array using bash script itself. This is when I went through the bash man page again and found an interesting new inbuilt mapfile
The use of this command is very simple
1
|
This made my life so simple. Now all I had to do was put all these values for arrays in different files and use the mapfile in the bash script and tell the users to just modify the files and no need to touch or modify the script.
Related Articles:
- 2010/10/13 Quick tip on zipping logs in real time.
- 2011/01/11 perl is faster than bash in some cases.
- 2010/11/20 Broadcast your shell thru port 5000
- 2010/09/01 Use the last command\’s output as input to a command without piping and bind to it to a key sequence in bash.
- 2010/06/29 Getting your wordpress self hosted stats on your console with bash script.
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.