Skip to content

Instantly share code, notes, and snippets.

@belenaj
Created January 11, 2016 06:53
Show Gist options
  • Save belenaj/4a3517a133baa36f4684 to your computer and use it in GitHub Desktop.
Save belenaj/4a3517a133baa36f4684 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Copyright
#
# Check for the correct # of arguments:
# Use this syntax or use: if [ $# -lt 3 ]
echo "$# arguments were supplied."
if [ $# -lt 3 ]
then
printf "%b" "Error. Not enough arguments.\n"
printf "%b" "usage: myscript file1 op file2\n" >&2
exit 1
elif [ $# -gt 3 ]
then
printf "%b" "Error. Too many arguments.\n" >&2
printf "%b" "usage: myscript file1 op file2\n" >&2
exit 2
else
printf "%b" "Argument count correct. Proceeding...\n"
input_file=$1
op=$2
output_file=$3
echo $input_file
cat $input_file | sort > $output_file
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment