<p>I have a file with fields separated by pipe characters and I want to print only the second field.  This attempt fails:</p>

<pre><code>$ cat file | awk -F| '{print $2}'
awk: syntax error near line 1
awk: bailing out near line 1
bash: {print $2}: command not found
</code></pre>

<p>Is there a way to do this?</p>

The pipe character needs to be escaped so that the shell doesn't interpret it.  A simple solution:
```
```
$ awk -F\| '{print $2}' file
```
```
Another choice would be to quote the character:
```
```
$ awk -F'|' '{print $2}' file
```
```