${x%% *} is a great way to remove everything except the first word in the $x variable. That is, given the text XXX YYY ZZZ , this syntax will delete everything after the first space.
Some examples:
$ x="aaa abbb" $ echo ${x%% *} aaa $ x="aaa abbb bccc defasdfs" $ echo ${x%% *} aaa
This is equivalent to:
$ x="aaa abbb bccc defasdfs" $ echo $x | awk '{print $1}' aaa
To make sure this is clear, let's give another example:
$ x="aaa abbb_bccc_defasdfs" $ echo ${x%%_*} aaa abbb
We look for the first character _ and delete it from this point to the end.
To learn more about these interesting commands, you can check out Reference Cards #String Operations .
Regarding the Google question, yes, these characters are not searchable through their search engine. Instead, I would advise you to use SymbolHound .
For example, the query $ {x %% *} shows a valuable result.
fedorqui
source share