Title: Understanding Unix process substitution behavior
Tags: unix
Question: ```awk '{print FILENAME, $0}' <(ls)  # output:   /dev/fd/4 file
awk '{print FILENAME, $0}' < <(ls) # output:   - file
```

In the above one-liners, the first one generates file descriptor and then the filename where as the second one generates the hypen (-) character and then the filename. Why this behavior?



Here is another answer: You can see it this way:

```awk '{print FILENAME, $0}' <(ls)
# is the same as
awk '{print FILENAME, $0}' output_of_ls_command
```

```awk``` will read a tmp file (created by ```bash```, let's name it as ```output_of_ls_command```(it's ```/dev/fd/4``` in your case))



```awk '{print FILENAME, $0}' < <(ls)
# is the same as
awk '{print FILENAME, $0}' < output_of_ls_command
```

```awk``` will read stdin (```bash``` read the tmp file, and send the content to ```awk```, ```FILENAME``` is ```-```)


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:02/14/14', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<unix>', 'Title': 'Understanding Unix process substitution behavior', 'ViewCount': 29, 'id': 21772906, 'user_AboutMe': '', 'user_AccountId': 1408518.0, 'user_DisplayName': 'Ibrahim Quraish', 'user_Reputation': 3729.0, 'user_Views': 400.0, 'user_id': 1335601.0}}