var="BASH"; echo "unix scripting" | awk '{gsub(/unix/,"'"${var}"'"); print}' var="BASH"; echo "unix scripting" | awk '{gsub(/unix/,"'"$(echo ${var})"'"); print}' var="BASH"; echo "unix scripting" | awk -v v="$var" '{sub(/unix/,v); print}'
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Using external variables in awk (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» mycmds in awk shell osx mac bash bashrc unix debug profile escape alias
» List manual pages and system... in awk shell osx mac bash cmd unix commands list man manpages
» Changing the Finder "Open Wi... in awk shell osx mac bash unix finder file application open menu contextual lsregister duti with wsupdate
» Get process ID (PID) via ps ... in awk ps kill shell osx mac bash unix process killall pid
» Counting lines in awk grep shell osx mac bash line unix count file sed directory lines wc
» Simple internet traffic summ... in awk shell osx mac bash unix web internet traffic summary tcpdump
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails