Parse Simple XML Files using Bash – Extract Name Value Pairs and Attributes
I have written up a simple routine parseXML to parse simple XML files to extract unique name values pairs and their attributes. The script extracts all xml tags of the format <abc arg1="hello">xyz</abc> and dynamically creates bash variables which hold values of the attributes as well as the elements. This is a good solution, if [...]
Custom Key Bindings / Keyboard Shortcuts in Bash
Bash is so powerful that you can keep digging and finding out newer secrets all the time. We already use bash keyboard bindings – Ctrl d to exit the terminal, Ctrl r for reverse search and so on. Now won’t it be convenient if you could assign keyboard bindings to commands of your choice, to [...]
Pass Bash Variables to Awk
Bash variables can’t be passed into awk, like one can with a lot of other commands. They need to be declared using the -v option. Here’s a code snippet which shows how. #!/bin/bash mainstring="abcdef" substring="cde" awk -v a="$mainstring" -v b="$substring" ‘BEGIN { print index(a,b) }’ The above awk command is for locating the position of [...]

Recent Comments
(1 weeks ago)
(1 weeks ago)
(2 weeks ago)
(3 weeks ago)