KandZ – Tuts

We like to help…!

Linux CLI 46 ๐Ÿง sed command

a - sed command and options
sed command(stream editor) is text processing tool.
It can perform basic text transformations on input stream(file or command output)
syntax โ†’ sed [options] 'script' inputfile
script โ†’ is the script to be executed by sed
common options: -i โ†’ Edit files in place (save the changes to the original file)
-e script โ†’ Add the script to the list of editing commands. This is typically used when you want to specify multiple scripts.
-f script_file โ†’ Read the editing commands from `script_file`.
-n โ†’ Suppress automatic printing of pattern space

b - sed common scripts
s/what/with โ†’ substitute what with with, s = replace
s/what/with/3 โ†’ substitute the 3rd what with with, 3 = 3rd occurence
s/what/with/3h โ†’ substitute the 3rd what with with and all others after the 3rd
s/what/with/g โ†’ substitute what with with all occurences, g = global
3 s/what/with/ โ†’ substitute what with with on line 3, 3 = line 3
n,md โ†’ deletes lines from n to m line, d = delete
n a\ newline โ†’ appends newline after line n, a=append
/pattern/p โ†’ prints lines containing specific pattern

c - sed examples
sed -n '=;p' example.txt prints line numbers
sed 's/This/That/g' example.txt replaces This with That
sed '/This/d' example.txt deletes all This
sed -e 's/This/That/g' -e 's/And/---/' example.txt replace multiple patterns
echo "s/This/That/g" scriptFile create a script file
sed -f scriptFile example.txt use a script file
sed -s 's/This/That/g' example.txt example1.txt replaces This with That in 2 files

Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!

Leave a Reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock