I ntroduction to Passing Variables to AWK AWK is one of the most famous commands to use and manipulate the string based files which can be parsed into fields using delimiters and the functionality can even extended with passing variables to awk. It is so much convenient to work with AWK due to its easiness and understandable scripting to accomplish some certain tasks such as filtering fields. The special parameter -v is used to pass bash variables or variables inside a script . The general syntax will look like the following. The most important thing is that for each variable that needs to be passed into awk script, they all need to be passed with repetitive -v use. awk -v var_name=value [-v var_name2=value2] 'AWK script' input_file In a sample input.txt file, say the content looks like as the following. If delimited with space, first column will be the count, second field is the user agent and third field is the agent version. $ cat input.txt 30 okhttp 5.0...
Yet another blog about Storage and Linux systems