bash-stdin-or-filename
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| bash-stdin-or-filename [2024/02/01 23:19] – created dblume | bash-stdin-or-filename [2024/02/19 14:31] (current) – Moving because now have stdin and stdout sections dblume | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Bash Stdin or Filename ====== | ||
| - | If you write a shell script and want it to run with either stdin or a filename, like so: | ||
| - | |||
| - | cat text.txt | script.sh | ||
| - | script.sh text.txt | ||
| - | |||
| - | There are some options: | ||
| - | |||
| - | <file bash script.sh> | ||
| - | # | ||
| - | awk -F, ' | ||
| - | </ | ||
| - | |||
| - | <file bash script.sh> | ||
| - | # | ||
| - | cat " | ||
| - | </ | ||
| - | |||
| - | <file bash script.awk> | ||
| - | #!/bin/awk -f | ||
| - | BEGIN{FS="," | ||
| - | </ | ||
bash-stdin-or-filename.1706858386.txt.gz · Last modified: 2024/02/01 23:19 by dblume