multiple sed expressions

Существует несколько способов выполнить несколько команд sed одновременно

Фигурные скобки { }

sed '{
/^pool 0/ i 0.fi.pool.ntp.org
/^pool\s[0-9]\.ubuntu/ d
} ' /etc/ntp.conf

После открывающей фигурной скобки можно нажать Enter и продолжить вводить команды

Можно применить несколько команд к одному файлу

.sed файл

Набор команд можно сохранить в виде файла.

Рассморим ntp.sed

cat ntp.sed

/^pool 0/ i 0.fi.pool.ntp.org
/^pool\s[0-9]\.ubuntu/ d

Теперь его можно применить к любому файлу

sed -f ntp.sed /etc/ntp.conf

Где -f означает file

man sed

-f script-file, --file=script-file add the contents of script-file to the commands to be executed

Ещё один способ выполнить несколько команд сразу - ипользовать -e

Читайте об этом в следующей статье

«--expression=script»

Article author: Andrei Olegovich

Похожие статьи
SED
find + sed
p: sed print
s: sed substitute
a i: append insert
Multiple commands
-e: --expression=script
d: Delete
sed via ssh
find + sed
Sustitution grouping
sed in vim
Linux
Bash
Bash Scripting
AWK
GREP

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: