Telegram Group & Telegram Channel
🔥 Bash-фишка дня: замена строк в файле без sed и awk

Иногда хочется быстро заменить строку в файле без сложных конструкций. Вот способ сделать это с чистым Bash и while read:

🛠 Скрипт: заменить слово в файле


#!/bin/bash

INPUT="config.txt"
OUTPUT="config_new.txt"
SEARCH="localhost"
REPLACE="127.0.0.1"

while IFS= read -r line; do
echo "${line//$SEARCH/$REPLACE}"
done < "$INPUT" > "$OUTPUT"


📌 Что тут происходит:

* IFS= read -r line — читаем файл построчно, без обрезки пробелов.
* ${line//$SEARCH/$REPLACE} — заменяем все вхождения $SEARCH на $REPLACE.
* Результат сохраняем в новый файл.

⚡️ Подходит, когда sed недоступен (да, бывает) или нужна более понятная логика замены.

👉@bash_srv



tg-me.com/bash_srv/76
Create:
Last Update:

🔥 Bash-фишка дня: замена строк в файле без sed и awk

Иногда хочется быстро заменить строку в файле без сложных конструкций. Вот способ сделать это с чистым Bash и while read:

🛠 Скрипт: заменить слово в файле


#!/bin/bash

INPUT="config.txt"
OUTPUT="config_new.txt"
SEARCH="localhost"
REPLACE="127.0.0.1"

while IFS= read -r line; do
echo "${line//$SEARCH/$REPLACE}"
done < "$INPUT" > "$OUTPUT"


📌 Что тут происходит:

* IFS= read -r line — читаем файл построчно, без обрезки пробелов.
* ${line//$SEARCH/$REPLACE} — заменяем все вхождения $SEARCH на $REPLACE.
* Результат сохраняем в новый файл.

⚡️ Подходит, когда sed недоступен (да, бывает) или нужна более понятная логика замены.

👉@bash_srv

BY Bash Советы




Share with your friend now:
tg-me.com/bash_srv/76

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

Export WhatsApp stickers to Telegram on iPhone

You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.

In many cases, the content resembled that of the marketplaces found on the dark web, a group of hidden websites that are popular among hackers and accessed using specific anonymising software.“We have recently been witnessing a 100 per cent-plus rise in Telegram usage by cybercriminals,” said Tal Samra, cyber threat analyst at Cyberint.The rise in nefarious activity comes as users flocked to the encrypted chat app earlier this year after changes to the privacy policy of Facebook-owned rival WhatsApp prompted many to seek out alternatives.telegram from us


Telegram Bash Советы
FROM USA