BASH_SRV Telegram 115
🔥 Регулярки для админов — Часть 2

Сегодня поговорим про замену и обработку данных с помощью sed


1. Маскирование конфиденциальных данных (пароли, токены)


sed -E 's/(password|token)=\S+/\1=***HIDDEN***/g' config.txt


Что делает:

- Находит password=что-то или token=что-то.
- Заменяет значение на ***HIDDEN***.


2. Удалить все цифры из файла


sed -E 's/[0-9]+//g' file.txt


Что делает:

- [] — диапазон символов.
- + — одно или больше вхождений.


3. Быстро поменять домен в конфиге


sed -E 's/(server_name\s+).*/\1newdomain.com/' /etc/nginx/sites-available/site.conf


Что делает:

- Захватывает server_name и всё после него.
- Заменяет домен на newdomain.com.


4. Удалить строки, содержащие определённые слова


sed -E '/(DEBUG|TRACE)/d' app.log


Что делает:

- /(...)/d — удаляет строки, содержащие DEBUG или TRACE.

👉@bash_srv
👍41



tgoop.com/bash_srv/115
Create:
Last Update:

🔥 Регулярки для админов — Часть 2

Сегодня поговорим про замену и обработку данных с помощью sed


1. Маскирование конфиденциальных данных (пароли, токены)


sed -E 's/(password|token)=\S+/\1=***HIDDEN***/g' config.txt


Что делает:

- Находит password=что-то или token=что-то.
- Заменяет значение на ***HIDDEN***.


2. Удалить все цифры из файла


sed -E 's/[0-9]+//g' file.txt


Что делает:

- [] — диапазон символов.
- + — одно или больше вхождений.


3. Быстро поменять домен в конфиге


sed -E 's/(server_name\s+).*/\1newdomain.com/' /etc/nginx/sites-available/site.conf


Что делает:

- Захватывает server_name и всё после него.
- Заменяет домен на newdomain.com.


4. Удалить строки, содержащие определённые слова


sed -E '/(DEBUG|TRACE)/d' app.log


Что делает:

- /(...)/d — удаляет строки, содержащие DEBUG или TRACE.

👉@bash_srv

BY Bash Советы




Share with your friend now:
tgoop.com/bash_srv/115

View MORE
Open in Telegram


Telegram News

Date: |

Invite up to 200 users from your contacts to join your channel "Doxxing content is forbidden on Telegram and our moderators routinely remove such content from around the world," said a spokesman for the messaging app, Remi Vaughn. To upload a logo, click the Menu icon and select “Manage Channel.” In a new window, hit the Camera icon. Hui said the time period and nature of some offences “overlapped” and thus their prison terms could be served concurrently. The judge ordered Ng to be jailed for a total of six years and six months. For crypto enthusiasts, there was the “gm” app, a self-described “meme app” which only allowed users to greet each other with “gm,” or “good morning,” a common acronym thrown around on Crypto Twitter and Discord. But the gm app was shut down back in September after a hacker reportedly gained access to user data.
from us


Telegram Bash Советы
FROM American