The parameter tag has no wiki summary.
2
votes
1answer
60 views
How can I pipe a path to pushd?
This seems like it should be easy enough to do, but I'm clearly not understanding something fundamental about piping output back and forth.
I'm trying to do something like this:
bundle show ...
1
vote
1answer
61 views
Writing command synopsis in standard man format
I am writing a script and in the usage() function I want to specify the usage.
My script uses either option1 or option2 or both. One of them is mandatory.
Is there a standard way to write it up?
6
votes
2answers
452 views
What does `:-` mean in a shell script
I saw this in the end of an awesome shell script but I can't understand the login here because I think it's being short-handed for a longer command.
spark ${@:-`cat`}
This apears at the end of this ...
2
votes
2answers
80 views
Getopts option processing, Is it possible to add a non hyphenated [FILE]?
I'm using getopts for all of my scripts that require advanced option parsing, and It's worked great with dash. I'm familiar with the standard basic getopts usage, consisting of [-x] and [-x OPTION]. ...
5
votes
3answers
124 views
Transform an array into arguments of a command?
I have an array of "options" of a command.
my_array=(option1 option2 option3)
I want to call this command in a bash script, using the values from array as options. So, command $(some magic here ...
4
votes
1answer
204 views
How to check if there are no parameters provided to a command?
How do you check if $* is empty? In other words, how to check if there were no arguments provided to a command?
0
votes
0answers
17 views
Alias syntax help [closed]
Possible Duplicate:
How to pass parameter to alias?
Error creating an alias for the find command
I would like to set up an alias, but all of the resources I see involve an alias with ...
3
votes
4answers
374 views
How can I create a empty file whose name begins with a dash?
How can we create a empty file with the unix name -stuff.
It means the name start with -. I tried with touch -stuff but it didn't work.
7
votes
1answer
274 views
How do ${0##*/} and ${0%/*} work?
I'm quite confused about the following regular expressions I found in a shell script:
${0##*/}
${0%/*}
How do they work?
2
votes
3answers
110 views
How to substitute awk argument?
I want simplify awk command for common usage so instead of writing awk '{print "rm -r"$4 }' each time I want to write myawk "rm -r"$4.
I've tried to write such function
myawk() { awk '{ print $1 }' ...
3
votes
2answers
347 views
Print shell arguments in reverse order
I am a bit stuck. My task is to print the arguments to my script in reverse order except the third and fourth.
What I have is this code:
#!/bin/bash
i=$#
for arg in "$@"
do
case $i
in
...
3
votes
3answers
252 views
How to pass a string parameter on bash function?
I have this code that does work:
get_parameter ()
{
echo "$query" | sed -n 's/^.*name=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"
}
But I want to replace the "name" with the parameter that I pass ...
2
votes
1answer
58 views
How to unset the positional parameters?
How do I do this:
set foo bar baz
unset # Something else here
echo $# # Should ouput 0
By doing set "", $# will still be 1 and not 0.
8
votes
2answers
308 views
How to safely pass variables to root-enabled scripts?
This question is totally general and not only applicable to my situation, but... I have a small busybox appliance where I want a non-root user to be able to execute a particular script with root ...
2
votes
2answers
113 views
How to escape < or > in a parameter in shell?
I'd like to use grep with a PCRE expression that contains the < character. Bash thinks I want to redirect, but I don't want to. How can I escape <?
2
votes
2answers
102 views
Want a seperate file to store mysql username, password, and database name
I have as script that dumps a mysql database, and compresses the file. What I want to do is have another (edit) file which can change the username, password and database name. Then somehow connecting ...
2
votes
2answers
133 views
Documentation of kernel parameters
Where can I find a technical description of the kernel parameters listed in /proc/sys (ob Linux)?
4
votes
5answers
468 views
Indexing and modifying Bash parameter array $@
Is it possible to refer to indexes in $@? I can't find any reference to use like the following anywhere in GrayCat's wiki, and the Advanced Scripting Guide and others assign this to a different ...
10
votes
3answers
878 views
How to pass parameters to an alias?
For bash script, I can use "$@" to access arguments. What's the equivalent when I use an alias?
5
votes
3answers
1k views
How do I split the $0 variable to find directory and relative paths in bash?
The $0 variable contains the path info of the script.
How can I change the path info to absolute path? I mean how to process ~, ., .. or similar?
How can I split the path info into directory and ...