New answers tagged arguments
If you have two zip files a.zip and b.zip in your current directory, then $ cp *.zip destination/ expands to $ cp a.zip b.zip destination/ The semantics for cp is to copy both a.zip and b.zip to destination. If you type $ cp \*.zip destination/ it simply "expands" to $ cp '*.zip' destination/ i.e. it will try to copy a single file named "*.zip" ...
On the contrary, unzip does too much. cp doesn't need to parse the filenames, all it needs to do is loop over them. Unzip, on the other hand, needs to see if an argument is a wildcard, check the directory listing to see what matches the wildcard and then loop over those. And note that the shell already is capable of matching and expanding wildcards, so ...
steeldriver is correct. What you should do is either: Use a command that reads in the standard input: #!/bin/bash fun=$(cat) echo "$fun" Or simply: #!/bin/bash cat Or, to convert standard input into positional parameters, use xargs: $ echo 1 | xargs ./test.sh Or, use the script the way it is supposed to be used (as coded): ./test.sh 1
Do this instead #!/bin/bash echo "$@" Then run it like this ./test.sh 1 It will echo 1, don't make it too complicated. And besides, why not just use echo? There is no reason to use this script.
Top 50 recent answers are included