Skip to main content
edited body
Source Link
Stéphane Chazelas
  • 585k
  • 96
  • 1.1k
  • 1.7k
process_data() {
  awk -Ff /dev/fd/3 3<< \EOF
  awk code here
EOF
}

Note that command line arguments can contain newline character, and while there's a length limit, it's general over a few hundred kilobyte.

awk '
  BEGIN {...}
  /.../ ...
  END {...}
'

If the issue is about embedding single quote characters in the awk script, another approach is to store the code in a variable:

awk_code=$(cat << \EOF
{print "'quoted' " $0}
EOF
)

And do:

process_data() {
  awk "$awk_code"
}
process_data() {
  awk -F /dev/fd/3 3<< \EOF
  awk code here
EOF
}

Note that command line arguments can contain newline character, and while there's a length limit, it's general over a few hundred kilobyte.

awk '
  BEGIN {...}
  /.../ ...
  END {...}
'

If the issue is about embedding single quote characters in the awk script, another approach is to store the code in a variable:

awk_code=$(cat << \EOF
{print "'quoted' " $0}
EOF
)

And do:

process_data() {
  awk "$awk_code"
}
process_data() {
  awk -f /dev/fd/3 3<< \EOF
  awk code here
EOF
}

Note that command line arguments can contain newline character, and while there's a length limit, it's general over a few hundred kilobyte.

awk '
  BEGIN {...}
  /.../ ...
  END {...}
'

If the issue is about embedding single quote characters in the awk script, another approach is to store the code in a variable:

awk_code=$(cat << \EOF
{print "'quoted' " $0}
EOF
)

And do:

process_data() {
  awk "$awk_code"
}
the parenthesis must be closed...
Source Link
Stéphane Chazelas
  • 585k
  • 96
  • 1.1k
  • 1.7k
process_data() {
  awk -F /dev/fd/3 3<< \EOF
  awk code here
EOF
}

Note that command line arguments can contain newline character, and while there's a length limit, it's general over a few hundred kilobyte.

awk '
  BEGIN {...}
  /.../ ...
  END {...}
'

If the issue is about embedding single quote characters in the awk script, another approach is to store the code in a variable:

awk_code=$(cat << \EOF
{print "'quoted' " $0}
EOF
) #random comment for edit purposes only

And do:

process_data() {
  awk "$awk_code"
}
process_data() {
  awk -F /dev/fd/3 3<< \EOF
  awk code here
EOF
}

Note that command line arguments can contain newline character, and while there's a length limit, it's general over a few hundred kilobyte.

awk '
  BEGIN {...}
  /.../ ...
  END {...}
'

If the issue is about embedding single quote characters in the awk script, another approach is to store the code in a variable:

awk_code=$(cat << \EOF
{print "'quoted' " $0}
EOF
) #random comment for edit purposes only

And do:

process_data() {
  awk "$awk_code"
}
process_data() {
  awk -F /dev/fd/3 3<< \EOF
  awk code here
EOF
}

Note that command line arguments can contain newline character, and while there's a length limit, it's general over a few hundred kilobyte.

awk '
  BEGIN {...}
  /.../ ...
  END {...}
'

If the issue is about embedding single quote characters in the awk script, another approach is to store the code in a variable:

awk_code=$(cat << \EOF
{print "'quoted' " $0}
EOF
)

And do:

process_data() {
  awk "$awk_code"
}
process_data() {
  awk -F /dev/fd/3 3<< \EOF
  awk code here
EOF
}

Note that command line arguments can contain newline character, and while there's a length limit, it's general over a few hundred kilobyte.

awk '
  BEGIN {...}
  /.../ ...
  END {...}
'

If the issue is about embedding single quote characters in the awk script, another approach is to store the code in a variable:

awk_code=$(cat << \EOF
{print "'quoted' " $0}
EOF
) #random comment for edit purposes only

And do:

process_data() {
  awk "$awk_code"
}
process_data() {
  awk -F /dev/fd/3 3<< \EOF
  awk code here
EOF
}

Note that command line arguments can contain newline character, and while there's a length limit, it's general over a few hundred kilobyte.

awk '
  BEGIN {...}
  /.../ ...
  END {...}
'

If the issue is about embedding single quote characters in the awk script, another approach is to store the code in a variable:

awk_code=$(cat << \EOF
{print "'quoted' " $0}
EOF

And do:

process_data() {
  awk "$awk_code"
}
process_data() {
  awk -F /dev/fd/3 3<< \EOF
  awk code here
EOF
}

Note that command line arguments can contain newline character, and while there's a length limit, it's general over a few hundred kilobyte.

awk '
  BEGIN {...}
  /.../ ...
  END {...}
'

If the issue is about embedding single quote characters in the awk script, another approach is to store the code in a variable:

awk_code=$(cat << \EOF
{print "'quoted' " $0}
EOF
) #random comment for edit purposes only

And do:

process_data() {
  awk "$awk_code"
}
Source Link
Stéphane Chazelas
  • 585k
  • 96
  • 1.1k
  • 1.7k
Loading