Question: I'm trying to get this script to `cat` a file and `grep` each line for `877` and for each line found, print the first column which is an IP and store it in hosts. It get stuck on `awk` every time. I run `sh -x some.sh` to see where it is hung up. Should I print to a file instead of a list? Why does it get stuck on `awk`?

```
hosts=()

FILENAME=/home/somethin/.hosts.conf

ips=`cat $FILENAME | grep -v '877'`

for line in $ips; do
     hosts=$(`awk '{print $1}'`)
done

echo $hosts

```

Answer: 
To answer this thread based on the original code, and a corrected version/code-review:

```
#ideally use variable names that do not exist as a command
hosts=()

FILENAME="/home/somethin/.hosts.conf"

ips=`cat $FILENAME | grep '322'`

for line in $ips; do
     hosts+=("`echo $line | awk '{print $1}'`")
     #alternative for shells not supporting the += operator:
     #hosts=("${hosts[@]}" "`echo $line | awk '{print $1}'`")
done

echo ${hosts[@]}

```

There are several issues to point out, that give you the impression your script is "*stuck on awk*"

* You are assigning host anew each time `hosts=$(`awk '{print $1}'`)`
* Intentionally or not, you are selecting the *inverse i.e. non-matches* with the grep flag `-v`.
* You are performing a nested command substitution in dollar and backtick notation, with input that doesn't contain commands: `$(`awk '{print $1}'`)` .
* awk is not given any input
* `echo variablename` will only print the first element of a bash array

Note: much can be performed with `awk` and `sed`, but both are rather intended as shortcuts to more verbose, but also better structured bash/shell skripts which are easier to extend later on. So there is a tradeoff, and there is nothing wrong in the way you started out with....
Try `echo $line | awk '{print $1}'`