This is my simple script
#!/bin/bash
echo $(awk '$2 ~ /$1/ {print $0}' numeri-telefonici.txt | cut -d' ' -f1)
and numeri-telefonici.txt
file is
00000 Alessandro
11312 Mark
unfortunately when I execute this script (./script.sh Alessandro
) an empty row is print:
, but If i execute awk '$2 ~ /Alessandro/ {print $0}' numeri-telefonici.txt | cut -d' ' -f1
I get successfully 00000
.
- How do I fix?