Warning: Undefined array key "socialize_RedditWidget" in /home/phpacd/websites/shkodenko.com/wp-content/plugins/socialize/frontend/socialize-services.php on line 166
Warning: Undefined array key "socialize_LinkedInWidget" in /home/phpacd/websites/shkodenko.com/wp-content/plugins/socialize/frontend/socialize-services.php on line 211
Warning: Undefined array key "socialize_PinterestWidget" in /home/phpacd/websites/shkodenko.com/wp-content/plugins/socialize/frontend/socialize-services.php on line 238
Warning: Undefined array key "socialize_PocketWidget" in /home/phpacd/websites/shkodenko.com/wp-content/plugins/socialize/frontend/socialize-services.php on line 279
Warning: Undefined array key "pocket_counter" in /home/phpacd/websites/shkodenko.com/wp-content/plugins/socialize/frontend/socialize-services.php on line 280
๐ง What does this Linux command do?
sed -n 'BEGIN,ENDp' /path/to/file.txt
At first glance, it looks simple. But this small command can save a lot of time when working with logs and large text files.
Let’s break it down:
-
sed
โ a stream editor for processing text;
-
-n
โ disables automatic output of every line;
-
BEGIN,END
โ defines the range of lines to process;
-
p
โ prints only the selected lines.
Example:
sed -n '100,150p' application.log
This will print only lines from 100 to 150 of the log file.
You can also use text patterns:
sed -n '/ERROR BEGIN/,/ERROR END/p' application.log
This extracts everything between two markers:
ERROR BEGIN
...
ERROR END
A very useful technique when you need to quickly inspect a specific part of a huge log file without opening it in an editor.
For example:
- debugging production issues;
- analyzing application errors;
- investigating server logs;
- checking deployment output.
Small Linux commands are often the tools that make engineers faster.
Do you use
sed
in your daily workflow? ๐จโ๐ป