'Linux Help keep getting new line error for line 6 dont know what the problem is
#!/bin/sh if ($#argv == 0) echo There are no arguments if ($#argv != 0) echo There are $#argv arguments
Solution 1:[1]
I'm not surprised you're getting errors; you have several syntax errors and incorrect constructs that would prevent your code from running on the Bourne shell (the interpreter indicated by your shebang line). I've fixed your code below so sh will actually run it:
#!/bin/sh
if [ "$#" == "0" ]; then
echo "There are no arguments"
fi
if [ "$#" != "0" ]; then
echo "There are $# arguments"
fi
That being said, you're testing for the same condition twice ("$#" == "0" / "$#" != "0"); I would refactor this to just a simple if/else instead of the two separate conditionals you have currently.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | plentyofcoffee |
