I have a small problem here.
I've written a script, which works fine. But there is a small problem.
The script takes 1 or 2 arguments. The 2nd arguments is a .txt file.
If you write something like my_script arg1 test.txt, the script will work. But when you write my_script arg1 < test.txt it doesn't.
Here is a demo of my code:
#!/bin/bash
if [[ $# = 0 || $# > 2 ]]
then
    exit 1
elif [[ $# = 1 || $# = 2 ]]
then
    #do stuff
    if [ ! -z $2 ]
    then
        IN=$2
    else
        exit 3
    fi
fi
cat $IN
How can I make it work with my_script arg1 < test.txt?
 
     
    