This question already has answers here:
Is there a "standard" format for command line/shell help text?
(11 answers)
Closed 7 years ago.
What is the convention for showing the usage of a bash script ?
Below is the help output for my script
Usage: my_script [options] [PORT]
Options:
--help print help and exit
--version print version and exit
Am i right in thinking that [ ] means optional
How do I signify an optional argument and a mandatory argument ?
A couple of commandline tools that i use frequently is "find" and "grep". While find runs happy without any parameters (all parameters are optional) grep needs at least a pattern. In case grep is invoked with no paramters at all it prints usage information like follows
Aufruf: grep [OPTION]... MUSTER [DATEI]...
"grep --help" liefert weitere Informationen.
Where MUSTER is the german word for pattern.
Related
This question already has answers here:
What's the magic of "-" (a dash) in command-line parameters?
(5 answers)
Closed 1 year ago.
I see this command:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
What does this to? What is the "-" called in bash?
This has nothing to do with bash. - has a very specific meaning when passed to the python binary:
-
Read commands from standard input (sys.stdin). [...]
Since, in your example,
curl outputs the downloaded file to stdout and
the shell pipe | passes curl's output to python's stdin,
python will execute the commands contained in the file downloaded by curl.
Note that this is a convention commonly found in various command-line utilities: Providing a single hyphen in place of a file name causes the command to read input from stdin instead of a file.
This question already has answers here:
What's the magic of "-" (a dash) in command-line parameters?
(5 answers)
Closed 1 year ago.
I tried to add generated ssh id_rsa to the gitlab-ci.
Command I have found is echo "$SSH_PRIVATE_KEY" | ssh-add -.
I can not find any information about param - that was added to command ssh-add.
How can I interprate this?
In a man I have found information about running it without any argument and some flags but add single dash is not describe there.
I used ubuntu latest image for this process
As #Aaron said
It's a reference to the standard input of the command, so the output of the piped echo
This question already has answers here:
Getting pids from ps -ef |grep keyword
(6 answers)
Closed 3 years ago.
I'm little bit new in sql command so please help me to clear this doubt
ps -ef|grep tomcat
This is not a SQL command,it's an unix/linux command check out forum answer below can clear your doubts.
https://askubuntu.com/questions/852206/what-does-ps-efgrep-processname-mean
In short :
look for lines containing processname in a detailed overview/snapshot of all current processes, and display those lines in linux command prompt environment
ps -ef says list all of the processes. (The -e option means every process, and the -f means use the "full" format in the listing.)
| says pipe the output of the previous command to the next command
grep tomcat say show (i.e. write to output) only those lines in the command's input that contain the string tomcat.
Combined, it means "show me the tomcat processes".
The "secret" to understanding a complicated Linux command is:
Understand the shell syntax; i.e. how |, <, >, $ and so on work.
Break the command line into its commands
Look up and read the manual entry for each command.
This question already has answers here:
Can I alias a subcommand? (shortening the output of `docker ps`)
(4 answers)
How to write an alias for "two" words [duplicate]
(2 answers)
Closed 5 years ago.
All the documentation I've looked at seems to indicate that in both aliases and shell functions, the name cannot contain spaces.
What I'm trying to do is make it more difficult for other admins (as root) to run a command against our Pass implementation (doc here : https://www.passwordstore.org/). It would still be possible, but I was hoping to turn a command like "pass rm $anyValueTheyInput" and alias that to, say "echo 'You can't do that'". Of course they're admins and they can change their aliases, but it would hopefully prevent accidental removal of passwords.
Is this possible in BASH? These will all be on RHEL or Centos boxes.
Aliasing whole commands complete with arguments is not possible in bash (if it's even possible in any UNIX shell at all).
What you can do is create a pass function that catches all the undesirable argument packs and forwards all other argument packs
to command pass:
pass()
{
if [ rm = "$1" ]; then
>&2 printf '%s\n' "You can't do that"
return 1
fi
#more checks... ?
#...
#forward the sanitized argument pack into the actual pass binary/script
command pass "$#"
}
This question already has answers here:
Using getopts to process long and short command line options
(32 answers)
Closed 8 years ago.
I want to write a bash shell script, it can accept parameters, and the parameter has prompt, example,
./test.sh --version=1.0
value 1.0 is the real parameter for my shell, and --version= is the prompt
is there any easy way to do it like this?
You should have have a look at man(1) getopt.
Depending what you mean by "easy" - using getopts should work. A bit of typing, but... Here are some examples to get you started:
http://rsalveti.wordpress.com/2007/04/03/bash-parsing-arguments-with-getopts/
How do I parse command line arguments in Bash?
http://spin.atomicobject.com/2011/03/30/parsing-arguments-in-bash-with-getopts/