Useful Bash Variables
Everytime I write a bash script, I have to look up one of these special bash variables and I always forget which one is which. Jotting it down so that I don’t have to google for them the next time. $@ – all arguments as a big string. $# – number of arguments passed in [...]
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)
(1 weeks ago)
(1 weeks ago)