You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## <a name="gotchas-and-tips"></a>Gotchas and Tips
2474
2476
2477
+
* using `$` for variables
2478
+
* only input record `$0` and field contents `$1`, `$2` etc need `$`
2479
+
* See also [unix.stackexchange - Why does awk print the whole line when I want it to print a variable?](https://unix.stackexchange.com/questions/291126/why-does-awk-print-the-whole-line-when-i-want-it-to-print-a-variable)
2480
+
2481
+
```bash
2482
+
$ # wrong
2483
+
$ awk -v word="apple" '$1==$word' fruits.txt
2484
+
2485
+
$ # right
2486
+
$ awk -v word="apple" '$1==word' fruits.txt
2487
+
apple 42
2488
+
```
2489
+
2490
+
* dos style line endings
2491
+
* See also [unix.stackexchange - filtering when last column has \r](https://unix.stackexchange.com/questions/399560/using-awk-to-select-rows-with-specific-value-in-specific-column)
0 commit comments