What do these symbols in some Linux terminal commands mean? [closed]
On AskUbuntu, I've seen a few commands around that look quite complicated, with lots of symbols in them. To get a better understanding of how these commands are built up, I'd like to know what the symbols stand for.
For example:
find ~/ -name \*.c -exec sed -i "s/cybernetnews/cybernet/g" {} \;
or even more complicated:
echo -e "\e[${i#*=}m$( x=${i%=*}; [ "${!x}" ] && echo "${!x}" || echo "$x" )\e[m"
I understand very well that adding parameters as -c
, --debug
, have certain effects on the main commmand. The meanings of these are in almost all cases to be found in the man
pages, so that's not really what I'm looking for.
Please, try in your answer to define what the symbols specifically do, instead of explaining the examples I gave. That could look like this:
" means 'argument': the main command uses anything within these symbols as its source
^ is used for ...
# is used for ...
Thanks in advance
See The Bash Reference Manual section called Shell-Operation and the Advanced Bash-Scripting Guide Chapter 3 (Special Characters).
I refer to those anytime I need to learn something new about shell scripting in ubuntu/linux.
I think you will find ABS Chapter 3 the easiest to navigate for your purposes. All the symbols are seen on the far left of the page with a description immediately below them.
Unfortunately you do have to go to the man pages, as the "symbols" may have different meanings depending on which command is reading them.
For instance, in your first command, the meaning of {} and \; depend on the find command (man find). The meaning of quotes on an argument to sed are dependent on either sed or bash (as it's a quoted parameter it can potentially be a shell thing). The ~/ is definitely a bash pattern expansion thing.
For the second complicated command, it's mostly echoing stuff, so you'll find most information on that in bash's man page.
To answer your comment to this, the redirection characters > < | are used to pipe stuff from, and into, files (the greater and lesser than signs), and to connect a command's output with another's input (the pipe |). See here for a nice tutorial on I/O redirection, this is a very powerful design feature of the Unix shell and toolset.
1st one searches for files ending on .c
from within directory ~/
and exec
utes sed
(streamline editor) where sed s
earches for cybernetnews
and changes it into cybernet
.
The 2nd one eludes me ... shows an empty result when executed.