Skip to main content
added 2 characters in body
Source Link
Ed Morton
  • 35.9k
  • 6
  • 25
  • 60

The way to run a shell command with awk variables by concatenation:

message="foobar"
cmd="echo \047"message"\047 | cut -c 33"
if ( (cmd | getline m) > 0 ) { print m }
else { print "Failed ..." | "cat>&2"; exit 1}
close(cmd)

Thanks Ed Morton, my first attempt was:

message="foobar"
"echo "message" | cut -c 33" | getline m
print m

The way to run a shell command with awk variables by concatenation:

message="foobar"
cmd="echo \047"message"\047 | cut -c 3
if ( (cmd | getline m) > 0 ) { print m }
else { print "Failed ..." | "cat>&2"; exit 1}
close(cmd)

Thanks Ed Morton, my first attempt was:

message="foobar"
"echo "message" | cut -c 3 | getline m
print m

The way to run a shell command with awk variables by concatenation:

message="foobar"
cmd="echo \047"message"\047 | cut -c 3"
if ( (cmd | getline m) > 0 ) { print m }
else { print "Failed ..." | "cat>&2"; exit 1}
close(cmd)

Thanks Ed Morton, my first attempt was:

message="foobar"
"echo "message" | cut -c 3" | getline m
print m
deleted 16 characters in body
Source Link
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97

The way to run a shell command with awk variables by concatenation:

message="foobar"
cmd="echo \047"message"\047 | cut -c "$((i+1))3
if ( (cmd | getline m) > 0 ) { print m }
else { print "Failed ..." | "cat>&2"; exit 1}
close(cmd)

Thanks Ed Morton, my first attempt was:

message="foobar"
"echo "message" | cut -c "$((i+1))3 | getline m
print m

The way to run a shell command with awk variables by concatenation:

message="foobar"
cmd="echo \047"message"\047 | cut -c "$((i+1))
if ( (cmd | getline m) > 0 ) { print m }
else { print "Failed ..." | "cat>&2"; exit 1}
close(cmd)

Thanks Ed Morton, my first attempt was:

message="foobar"
"echo "message" | cut -c "$((i+1)) | getline m
print m

The way to run a shell command with awk variables by concatenation:

message="foobar"
cmd="echo \047"message"\047 | cut -c 3
if ( (cmd | getline m) > 0 ) { print m }
else { print "Failed ..." | "cat>&2"; exit 1}
close(cmd)

Thanks Ed Morton, my first attempt was:

message="foobar"
"echo "message" | cut -c 3 | getline m
print m
added 111 characters in body
Source Link
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97

The way to run a shell command with awk variables by concatenation:

message="ABC"message="foobar"
cmd="echo \047"message"\047 | cut -c 3""$((i+1))
if ( (cmd | getline m) > 0 ) { print m }
else { print "Failed ..." | "cat>&2"; exit 1}
close(cmd)

Thanks Ed Morton., my first attempt was:

message="foobar"
"echo "message" | cut -c "$((i+1)) | getline m
print m

The way to run a shell command with awk variables by concatenation:

message="ABC"
cmd="echo \047"message"\047 | cut -c 3"
if ( (cmd | getline m) > 0 ) { print m }
else { print "Failed ..." | "cat>&2"; exit 1}
close(cmd)

Thanks Ed Morton.

The way to run a shell command with awk variables by concatenation:

message="foobar"
cmd="echo \047"message"\047 | cut -c "$((i+1))
if ( (cmd | getline m) > 0 ) { print m }
else { print "Failed ..." | "cat>&2"; exit 1}
close(cmd)

Thanks Ed Morton, my first attempt was:

message="foobar"
"echo "message" | cut -c "$((i+1)) | getline m
print m
added 255 characters in body
Source Link
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97
Loading
Source Link
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97
Loading