замена файла на месте для n-го соответствия шаблону

На самом деле в MATE Desktop это невозможно, но вы можете попробовать запросить эту функцию в GitHub , например, в репозитории Caja или в панели MATE ..

1
24.10.2019, 01:19
1 ответ

Вместо сохранения в переменных поместите все выходные данные, по одному на строку, в файл, скажем, outf Тогда сделайте это:

$ sed -e "\\#${input1}#R outf" a

Предполагается, что вы используете GNU sed. Как только вы будете удовлетворены изменениями, введите опцию -i.

Пояснение:

° Alternate delimiter needs to escaped by a backslash. In our case, # is the delimiter, so we escape it with a backslash.
° Wait a minute but I see two of them here, you'll be asking. Well coz, before what we write on the command line gets to sed is seen n processed by the shell. So since backslash is special within double quotes, we need to double it so that after shell has seen it, it shall be presented as one to sed. So the Universe is happy.
° Now comes the R command. This is a nonstandard command given by Gnu folks,  and is precisely what the doctor ordered for your scenario. It will print one line each time it is invoked and place that line after the current input line is printed.

********/Финиш.

0
27.01.2020, 23:58

Теги

Похожие вопросы