Из man bash (где-то после строки 3813):
! Start a history substitution, except when followed by a blank,
newline, carriage return, = or ( (when the extglob shell option
is enabled using the shopt builtin).
[...]
$ The last word. This is usually the last argument, but will
expand to the zeroth word if there is only one word in the line.
Итак, !$ вспомнит последний аргумент из последней команды из истории.
Вот несколько примеров и эквивалентов:
$ echo foo bar
foo bar
$ echo !$ # recall the last argument from the last command from history
echo bar
bar
$ echo foo bar
foo bar
$ echo !:$ # the same like `!$'
echo bar
bar
$ echo foo bar
foo bar
$ echo !:2 # recall the second (in this case the last) argument from the last command from history
echo bar
bar
$ echo foo bar
foo bar
$ echo $_ # gives the last argument from the last command from history
bar
$ echo foo bar
foo bar
$ echo Alt+. # pressing Alt and . (dot) in the same time will automatically insert the last argument from the last command from history
bar
$ echo foo bar
foo bar
$ echo Alt+_ # the same like when you press Alt+.
bar
$ echo foo bar
foo bar
$ echo Esc. # the same like when you press Alt+.
bar
Все они будут работать только внутри интерактивной оболочки. Но если вы используете эту команду из своего вопроса внутри скрипта, как вы сказали, что вы его сеете, то все по-другому: при запуске скрипта это начнется в новой оболочке, неинтерактивной оболочке, поэтому история расширение не имеет никакого эффекта в этом случае, поэтому команда:
echo "An Example" > !$
создает файл !$, если нет (в противном случае перезаписывает его), и записывает в него An Example. [!d7 ]
Я думаю, что команда, которую вы ищете, это:
$ systemctl list-dependencies --reverse NetworkManager-wait-online.service
NetworkManager-wait-online.service
● └─network-online.target
● └─hddtemp.service
Из man systemctl:
list-dependencies [NAME]
Shows units required and wanted by the specified unit. This
recursively lists units following the Requires=, Requisite=,
ConsistsOf=, Wants=, BindsTo= dependencies. If no unit is
specified, default.target is implied.
By default, only target units are recursively expanded. When --all
is passed, all other units are recursively expanded as well.
Options --reverse, --after, --before may be used to change what
types of dependencies are shown.
--reverse
Show reverse dependencies between units with list-dependencies,
i.e. follow dependencies of type WantedBy=, RequiredBy=, PartOf=,
BoundBy=, instead of Wants= and similar.
Я думаю, что команда, которую вы ищете, это:
$ systemctl list-dependencies --reverse NetworkManager-wait-online.service
NetworkManager-wait-online.service
● └─network-online.target
● └─hddtemp.service
Из man systemctl:
list-dependencies [NAME]
Shows units required and wanted by the specified unit. This
recursively lists units following the Requires=, Requisite=,
ConsistsOf=, Wants=, BindsTo= dependencies. If no unit is
specified, default.target is implied.
By default, only target units are recursively expanded. When --all
is passed, all other units are recursively expanded as well.
Options --reverse, --after, --before may be used to change what
types of dependencies are shown.
--reverse
Show reverse dependencies between units with list-dependencies,
i.e. follow dependencies of type WantedBy=, RequiredBy=, PartOf=,
BoundBy=, instead of Wants= and similar.
Я думаю, что команда, которую вы ищете, это:
$ systemctl list-dependencies --reverse NetworkManager-wait-online.service
NetworkManager-wait-online.service
● └─network-online.target
● └─hddtemp.service
Из man systemctl:
list-dependencies [NAME]
Shows units required and wanted by the specified unit. This
recursively lists units following the Requires=, Requisite=,
ConsistsOf=, Wants=, BindsTo= dependencies. If no unit is
specified, default.target is implied.
By default, only target units are recursively expanded. When --all
is passed, all other units are recursively expanded as well.
Options --reverse, --after, --before may be used to change what
types of dependencies are shown.
--reverse
Show reverse dependencies between units with list-dependencies,
i.e. follow dependencies of type WantedBy=, RequiredBy=, PartOf=,
BoundBy=, instead of Wants= and similar.