
Search For Patterns Within Files With Grep DistroTube
video description
Date: 2022-03-30
Comments and reviews: 9
Chris
Thanks for posting this. Something a little different than tiling window managers et al.
cat is actually for taking 2 or more files and catinating the output. So, sticking grep at the end of cat is perfectly fine. Or if you are looking to edit specific lines you can cat the file, use grep, and then use sed. Stick awk in there to the search ny a specific colum, then send it to lpr to print it out.
The whole point of UNIX and Linux is streaming information, which is how the command line is set up. MS-DOS is the same way, with less utilities already available. You'd have to write a program to do things like grep, awk, and sed.
reply
Thanks for posting this. Something a little different than tiling window managers et al.
cat is actually for taking 2 or more files and catinating the output. So, sticking grep at the end of cat is perfectly fine. Or if you are looking to edit specific lines you can cat the file, use grep, and then use sed. Stick awk in there to the search ny a specific colum, then send it to lpr to print it out.
The whole point of UNIX and Linux is streaming information, which is how the command line is set up. MS-DOS is the same way, with less utilities already available. You'd have to write a program to do things like grep, awk, and sed.
reply
Casual_Logic
Another very cool use for grep is when using ps -ef to list all processes. You can grep to filter specific info like a process name, or user name. Pretty much any process. EG-You can use that to determine what the process ID number is of a specific process that isn't working properly in order to use kill -9 the process ID if it were giving you trouble and needed to be shutdown.
For example:
ps -ef - grep bash
ps -ef - grep username
etc.....
reply
Another very cool use for grep is when using ps -ef to list all processes. You can grep to filter specific info like a process name, or user name. Pretty much any process. EG-You can use that to determine what the process ID number is of a specific process that isn't working properly in order to use kill -9 the process ID if it were giving you trouble and needed to be shutdown.
For example:
ps -ef - grep bash
ps -ef - grep username
etc.....
reply
C-V-D
My favorite grep function acts like sed. Extract a substring from a line that contains a string that doesn't have to be part of that substring.
echo -e -now\nis the time for all\ngood--grep -Po -the \K.-?(?= for)-
grep -Po -wlan0.-inet \K.-?(?=/)-
reply
My favorite grep function acts like sed. Extract a substring from a line that contains a string that doesn't have to be part of that substring.
echo -e -now\nis the time for all\ngood--grep -Po -the \K.-?(?= for)-
grep -Po -wlan0.-inet \K.-?(?=/)-
reply
Birk
Not using more commands or programs than necessary is not really important for use on the command line. But it is useful in scripts, as it potentially reduces dependencies and runtime.
reply
Not using more commands or programs than necessary is not really important for use on the command line. But it is useful in scripts, as it potentially reduces dependencies and runtime.
reply
Enderger
Can you do a video/stream where you let your viewers send in links to their dotfiles to be critiqued by you? It would help highlight good and bad practices found in such files.
reply
Can you do a video/stream where you let your viewers send in links to their dotfiles to be critiqued by you? It would help highlight good and bad practices found in such files.
reply
Nachum
Hey DT, regarding streaming cat into grep because you just used it, the better way is writing the grep command and pressing alt-. To bring the argument from the previous command.
reply
Hey DT, regarding streaming cat into grep because you just used it, the better way is writing the grep command and pressing alt-. To bring the argument from the previous command.
reply
Frank
Grep is full of bloat and clearly violates the Unix philosophy. Instead of doing only one thing right, it does also read files and count lines. Worse feature creep than SystemD.
reply
Grep is full of bloat and clearly violates the Unix philosophy. Instead of doing only one thing right, it does also read files and count lines. Worse feature creep than SystemD.
reply
Jeetaditya
Do you plan on doing a video on text manipulation in the command line? I have touched on it using sed but I realise it's the tip of the iceberg
reply
Do you plan on doing a video on text manipulation in the command line? I have touched on it using sed but I realise it's the tip of the iceberg
reply
seocamo
you should use ripgrep, it is a FAST grep, so much faster ... and used with fzf ,,, it give you a fuzzy search in term or VIM
reply
you should use ripgrep, it is a FAST grep, so much faster ... and used with fzf ,,, it give you a fuzzy search in term or VIM
reply
Add a review, comment
Other channel videos















