#! /bin/sh # fd = name from stdio.h # 0 = stdin # 1 = stdout # 2 = stderr # # 1>&2 redirects stdout to stderr # > file redirects stdout to file, same as 1> file # 2> file redirects stderr to file # cmd1|cmd2 pipe cmd1 stdout to cmd2 stdin # |& pipe stdout and stderr if [ "$#" -eq "2" ]; then N="$1" FILE="$2" else echo "Usage: $0 N FILE" 1>&2 exit 1 fi echo "N = $N, FILE = $FILE" # sample runs: # $ bash args.sh a bb cc # Usage: args.sh N FILE # $ bash args.sh a bb # N = a, FILE = bb # $