-o in Linux terminal (Dash o); What does it mean?
In most cases, -o will stand for output, but it's not a defined standard. It can potentially mean anything the developer wanted it to mean.
The only way someone can know which commands is to use a command line option of --help, -h, or something -? to display a simple list of commands. Again because the developer of the program chooses the possible input arguments and their meaning might differ from program to program.
The safest way to know is typically to run
man gcc
replacing the second part with the program name you want.
man <program name>
This lists a full guide for the program with a lot more detail and is usually well formatted to read on a terminal. Just press Q when you’re finished reading it.
What is the -o option in GCC?
See https://man7.org/linux/man-pages/man1/gcc.1.html. Under the Synopsis section, you will see the -o option.
Regarding
Well OK, the compiler knows where to look for
stdio.h
, but the executable must be linked tostdio.o
, mustn't it? Where does thestdio.o
file reside?
The answer to the first question is "No". Since the answer to the first question is "No", the second question is not relevant.
The functions and variables declared in stdio.h
need not be in stdio.o
. They are usually in a library (.a
or .so
) which are found in one of the directories where the linker looks for library files.
In general, there is no rule that each .h
file has a corresponding .o
file. It is possible to have the functions and variables declared in a .h
file to be implemented in multiple .c
files that will result in multiple .o
files. It is also possible to have functions and variables declared in multiple .h
files to be implemented in one .c
file. How these are organized varies from project to project.
Each .c
file, on the other hand, has a corresponding .o
file (I haven't seen any platforms where multiple .c
files can be compiled to create one .o
file). All the .o
files resulting from compiling the .c
files are linked together to create an executable.
What's the magic of - (a dash) in command-line parameters?
If you mean the naked -
at the end of the tar
command, that's common on many commands that want to use a file.
It allows you to specify standard input or output rather than an actual file name.
That's the case for your first and third example. For example, the cdrecord
command is taking standard input (the ISO image stream produced by mkisofs
) and writing it directly to /dev/dvdrw
.
With the cd
command, every time you change directory, it stores the directory you came from. If you do cd
with the special -
"directory name", it uses that remembered directory instead of a real one. You can easily switch between two directories quite quickly by using that.
Other commands may treat -
as a different special value.
What does set -e mean in a bash script?
From help set
:
-e Exit immediately if a command exits with a non-zero status.
But it's considered bad practice by some (bash FAQ and irc freenode #bash FAQ authors). It's recommended to use:
trap 'do_something' ERR
to run do_something
function when errors occur.
See http://mywiki.wooledge.org/BashFAQ/105
What is the meaning of -n, -z, -x, -L, -d, etc... in Shell Script?
IMHO best way is you could simply do man test
for all these details. It is very well explained there. As follows is the text from man page. For BASH conditional expressions look for link https://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html too once.
-b FILE
FILE exists and is block special
-c FILE
FILE exists and is character special
-d FILE
FILE exists and is a directory
-e FILE
FILE exists
-f FILE
FILE exists and is a regular file
-g FILE
FILE exists and is set-group-ID
-G FILE
FILE exists and is owned by the effective group ID
-h FILE
FILE exists and is a symbolic link (same as -L)
-k FILE
FILE exists and has its sticky bit set
-L FILE
FILE exists and is a symbolic link (same as -h)
-O FILE
FILE exists and is owned by the effective user ID
-p FILE
FILE exists and is a named pipe
-r FILE
FILE exists and read permission is granted
-s FILE
FILE exists and has a size greater than zero
-S FILE
FILE exists and is a socket
-t FD file descriptor FD is opened on a terminal
-u FILE
FILE exists and its set-user-ID bit is set
-w FILE
FILE exists and write permission is granted
-x FILE
FILE exists and execute (or search) permission is granted
For expressions in man test
it is given:
( EXPRESSION )
EXPRESSION is true
! EXPRESSION
EXPRESSION is false
EXPRESSION1 -a EXPRESSION2
both EXPRESSION1 and EXPRESSION2 are true
EXPRESSION1 -o EXPRESSION2
either EXPRESSION1 or EXPRESSION2 is true
-n STRING
the length of STRING is nonzero
STRING equivalent to -n STRING
-z STRING
the length of STRING is zero
STRING1 = STRING2
the strings are equal
STRING1 != STRING2
the strings are not equal
INTEGER1 -eq INTEGER2
INTEGER1 is equal to INTEGER2
INTEGER1 -ge INTEGER2
INTEGER1 is greater than or equal to INTEGER2
For conditional expressions info go for man bash
it gives info as follows too.
CONDITIONAL EXPRESSIONS
Conditional expressions are used by the [[ compound command and the test and [ builtin commands to test file attributes and
perform string and
arithmetic comparisons. Expressions are formed from the following unary or binary primaries. If any file argument to one of
the primaries is
of the form /dev/fd/n, then file descriptor n is checked. If the file argument to one of the primaries is one of /dev/stdin,
/dev/stdout, or
/dev/stderr, file descriptor 0, 1, or 2, respectively, is checked.Unless otherwise specified, primaries that operate on files follow symbolic links and operate on the target of the link, rather
than the link
itself.When used with [[, The < and > operators sort lexicographically using the current locale.
What are the options with - (dash) on Linux terminal command mean?
Every U*x system comes with manual pages, and they are easy to find on the web as well.
man chmod
documents the chmod
command, including its options; man man
documents the man
command itself, etc.
GNU ships documentation in a system called Info which is less ubiquitous but more featureful (clickable links for cross-references, footnotes, etc). Typically, you will find a brief man page which directs you to Info for the full documentation.
On Linux systems, man intro
is a gentler introduction to get you started with the system. (There is no intro
command; the man page is simply an introduction to Life in Linux.)
The tutorials you have consulted don't seem very convincing if they failed to mention the existence of standard, high-quality on-line documentation within the system itself.
How to repeat a dash (hyphen) in shell
This throws an error:
$ printf '-%.0s' {1..100}; echo ""
bash: printf: -%: invalid option
printf: usage: printf [-v var] format [arguments]
This works fine under bash
:
$ printf -- '-%.0s' {1..100}; echo ""
----------------------------------------------------------------------------------------------------
For other shells, try:
printf -- '-%.0s' $(seq 100); echo ""
The problem was the printf
expects that -
starts an option. As is common among Unix/POSIX utilities in this type of situation, --
signals to printf
to expect no more options.
Related Topics
Signal Handling in Asm: Why am I Receiving Sigsegv When Invoking the Sys_Pause Syscall
Bash: Run an Executable File in Background
Split Files Using Tar, Gz, Zip, or Bzip2
Check If Directory Mounted with Bash
How to Add .So File to the Java.Library.Path in Linux
Svn Error: Can't Convert String from Native Encoding to 'Utf-8'
Execute Two Commands with Docker Exec
Linux Bash: Setting Iptables Rules to Allow Both Active and Passive Ftp
Fast String Search in a Very Large File
Difference Between Virtual Page and Page Frame
How to Imshow with Invisible Figure in Matlab Running on Linux
Bpf Verifier Rejects Code: "Invalid Bpf_Context Access"
Linux How to Copy But Not Overwrite
What's an Alternative for Dtrace on Linux
How to Find Ports Opened by Process Id in Linux
Linux Process in Background - "Stopped" in Jobs