I have script that prints out few lines of text. This text is used as configuration by other process.
When I normally run program I redirect standard output to file which is fine:
./generateConfig.sh > normal.cfg
But the problem is that normal.cfg is really constant and I would like to give user a choice to print to file or on the screen by providing additional parameter (like -o, without parameter arguments).
if the script content is:
#!/bin/bash echo "18.104.22.168"
How would I parametrize output so that depending on args it will print out to file or stdout?
This does not seem to work:
#!/bin/bash output="/dev/stdout" if [ $# -gt 0 ]; then output="normal.cfg" fi echo "22.214.171.124" > $output