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 "188.8.131.52"
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 "184.108.40.206" > $output