Насколько я вижу, что это делает то, в чем я нуждаюсь (но я не знаю точно почему).
[Unit]
Description=Log Traffic
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target
[Service]
ExecStart=/usr/local/bin/perl /home/me/log_traffic.pl --stop
Type=oneshot
Следующее должно работать, обновленное для разделения пробела:
#!/usr/bin/awk -f
# NR is the current line number (doesn't reset between files)
# FNR is the line number within the current file
# So NR == FNR takes only the first file
NR == FNR {
# Mark the current line as existing, via an associative array.
found[$0]=1
# Skip to the next line, so we don't go through the next block
next
}
{
# Take the columns we're looking for
cols = substr($0,115,11)
# Strip whitespace (space and tab) from the beginning (^) and end ($)
gsub(/^[ \t]+/,"", cols)
gsub(/[ \t]+$/,"", cols)
# Check the associative array to see if this was in the first file
# If so, print the full line
if(found[cols]) print;
}
Поместите его в файл и вызов с одним из следующих
awk -f script.awk patterns.txt full.txt
./script.awk patterns.txt full.txt
found[cols]
Вы на самом деле выделяете и ни на что устанавливаете ()found[cols]
. Выполнениеfound[$0]
(без=1
), и затем протестируйте сif(cols in found)
намного более эффективно (память и мудр CPU). – Stéphane Chazelas 24.04.2013, 21:31