User Tools

Site Tools


bash-stdin-or-filename

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bash-stdin-or-filename [2024/02/01 23:19] – created dblumebash-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> 
-#!/usr/bin/env sh 
-awk -F, '...' "${1:-/dev/stdin}" 
-</file> 
- 
-<file bash script.sh> 
-#!/usr/bin/env sh 
-cat "$@" | awk -F, '...' 
-</file> 
- 
-<file bash script.awk> 
-#!/bin/awk -f 
-BEGIN{FS=","} ... 
-</file> 
bash-stdin-or-filename.1706858386.txt.gz · Last modified: 2024/02/01 23:19 by dblume