I use two commands to scan for channels:
awk 'BEGIN{while(" w_scan -c PL -x " | getline ) print >> "tmp" }'
awk 'BEGIN{while(" w_scan -I tmp -E 0 -t 3 -F " | getline) print >> "channels" }'
I want to do the same, but with one command. How to simplify to skip writing to tmp?
Thank you for your help.
EDIT:
I tried this command, but it does not work:
awk 'BEGIN { while (" w_scan -c PL -x " | getline ){split($0, tab, RS) system( " w_scan -I \047" tab[1] "\047 -E 0 -t 3 -F " ">>" "channels" )}}'
Result error -> enter link description here
EDIT-1
When I use this script does not work.
run.awk
BEGIN {
while (" w_scan -c PL -x " | getline ) {
split($0, tab, RS)
system( " w_scan -I '\047'" tab[1] "'\047' -E 0 -t 3 -F >> channels" )
}
}
Result error → enter link description here
When I use this script, it works well.
sh script
#!bin/bash
awk 'BEGIN{while(" w_scan -c PL -x " | getline ) print >> "tmp" }'
awk 'BEGIN{while(" w_scan -I tmp -E 0 -t 3 -F " | getline) print >> "channels" }'
Result –> enter link description here
Just stick them both in the
BEGINblock:If you want the whole thing on one line you can separate the commands with semicolon:
Edit
You’re accessing
tmpin both loops, make sure it’s written before the second loop withcloseandsync:run.awk
Execute with: