Его можно пропустить, если это последний символ строки события.
Сначала мы проверяем, что означает ^ string1 ^ string2 ^
из man bash
:
^string1^string2^
Quick substitution. Repeat the previous command,
replacing string1 with string2. Equivalent to
``!!:s/string1/string2/'' (see Modifiers below).
Таким образом, это эквивалентно s / string1 / string2 /
. Прочтите документацию по модификатору s
:
s/old/new/
Substitute new for the first occurrence of old in the event line.
Any delimiter can be used in place of /. The final delimiter
is optional if it is the last character of the event line. The
delimiter may be quoted in old and new with a single backslash.
If & appears in new, it is replaced by old. A single backslash
will quote the &. If old is null, it is set to the last old
substituted, or, if no previous history substitutions took place,
the last string in a !?string[?] search.
Похоже, что ваше приложение $ получает запятую, добавленную для других имен пакетов, чем VIM. Попробуйте удалить запятые из приложений
или Попробуйте
sudo apt-get install $(echo $app | sed 's/,//g') -y
вместо
sudo apt-get install $app -y
и
sudo pip install -U $(echo $app | sed 's/,//g')
вместо
sudo pip install -U $app
Ответ в Милине, что я должен заменить sudo apt-get install $ app -y
с Sudo apt-get install install $ (echo $ app | sed 's /// g') - у
было решение.
Вы можете удалить все заднивые запятые (,
), следуя каждому участнику массива, чтобы вам не нужна дополнительная модификация для вашего APT-GET Установите команду
. Таким образом, ваш сценарий может выглядеть следующим образом:
#!/bin/bash
apps=(
'python-dev'
'python-pip'
'python-numpy'
'python-scipy'
'python-matplotlib'
'ipython'
'ipython-notebook'
'python-pandas'
'python-sympy'
'python-nose'
'python-picamera'
'openssh-client'
'openssh-server'
'vim'
)
sudo apt-get update
# Loop over apps and install each one with default 'yes' flag
for app in "${apps[@]}"
do
sudo apt-get install $app -y
done