I have a following bash script I encountered on the web that prints the power set of a given lines of elements.
p() { [ $# -eq 0 ] && echo || (shift; p "$@") |
while read r ; do echo -e "$1 $r\n$r"; done }
after the first && there is echo that does not have any argument.
Here is the code to test it:
p $(echo -e "1\n2\n3")
I have a shell script that accepts an argument and uses that in the script. So to run the script I type
/path/to/script argument
The problem is when trying to setup that file to run using the at utility. I have tried
at -f /path/to/script argument 17:45
at -f '/path/to/script argument' 17:45
but neither of these options work.
My Bash-Script should accept arguments and options.
Moreover arguments and options should be passed to another script.
The second part I've solved:
for argument in "$@"; do
options $argument
done
another_script $ox $arguments
function options {
case "$1" in
-x) selection=1
-y) selection=2
-h|--help) help_message;;
-*) ox="$ox $1";;
*) arguments="$arguments $1";;
esa
I have created a script which takes parameters and arguments.
This is my first question.
I'm trying to make a small script with options and I'm using getopts to do it.
I am trying to automate some of my stuff and facing a issue, the problem boils down to escaping the value that is being passed as a argument to the script.
myScript.sh
#!/bin/bash
loadPatch -name $1
where $1 is the first argument and can have value like 'p12.9.5-bug34'
Running it as
myScript p12.9.5-bug34
produces no result. I checked with echo $?
I'm sorry if this doesn't go here, but I'm in depserate need of help with my last unix homework.
Anyways, I'm taking summer classes, and one of them is UNIX. I've understood everything thus far, but I'm having a killer time with how my instructor has worded the problems for shell scripting.
I'd like to use variable as condition in case statement. Something similar to:
#!/bin/sh
ALLOWED_SERVICES=tomcat6|james;
case $1 in
$ALLOWED_SERVICES )
service $1 restart
;;
* )
echo "Unsupported argument"
;;
esac
This doesn't work.
I'm launching a java program from a shell script like this:
JAVA_OPTS=
CLASSPATH=
JMX_OPTS=
java $JAVA_OPTS -cp $CLASSPATH $JMX_OPTS
And launched program expects user to type another argument. It can't be specified in the list of arguments the program was launched with.