How to pass bash parameter to awk script?

You can pass variables to your awk script directly from the command line.

You can pass variables to your awk script directly from the command line. Change this line: filetime$'$colnumber'++; To: filetimecolnumber++; And run: ls -al | awk -f . /myawk.

Awk colnumber=5 If you really want to use a bash wrapper: #! /bin/bash var1=$1 awk -f myawk. Awk colnumber=$var1 (with the same change in your script as above.) If you want to use environment variables use: #!

/bin/bash export var1=$1 awk -f myawk. Awk and: filetimeENVIRON"var1"++; (I really don't understand what the purpose of your awk script is though. The last part could be simplified to: END { print filetimecolnumber,colnumber; } and parsing the output of ls is generally a bad idea.

).

The sense is combine bash and awk. The input parameter I get only for example, bash script is more complicate. – user710818 Dec 19 at 13:05 3 I'm not sure I understand you, so added more options.

You can't have plain shell substitution inside your awk script, that just will not work - the shell only does substitutions on its parameters, not inside random files you specify on the command line (it doesn't even check what is a file and what is not in the general case). – Mat Dec 19 at 13:10.

The easiest way to do it: #! /bin/bash var=$1 awk -v colnumber="${var}" -f /your/script But within your awk script, you don't need the $ in front of colnumber. HTH.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions