Read full details here: How to find files containing specific text in Linux? Ubuntu, Debian, Mint, CentOS, Fedora and any Linux distro
Very often new users would dwell on Google trying to find the correct command to find files containing specific text. This is particularly important when you’re tying to follow a badly written guide of forum post that says something like replace 0 with 1 in this line which will fix PulseAudio configured for per-user sessions … (warning)
This guide shows a bunch of commands that you can use to find files containing specific text in Linux, namely Ubuntu, Debian, Mint, CentOS, Fedora and any Linux distro.
This guide will work for any Linux distributions, namely -
To find files containing specific text, you are possibly better off
using the grep command. The grep command can find and search a specific
text from all files quickly.
Now there’s a small problem, depending on your Linux, BSD or Unix distro, Find command can be slightly different (in terms of Syntaxes). So I will outline all possible combinations, you can just try one at a time to determine which one best suites you.
Read the rest of it here: How to find files containing specific text in Linux? Ubuntu, Debian, Mint, CentOS, Fedora and any Linux distro
Very often new users would dwell on Google trying to find the correct command to find files containing specific text. This is particularly important when you’re tying to follow a badly written guide of forum post that says something like replace 0 with 1 in this line which will fix PulseAudio configured for per-user sessions … (warning)
PULSEAUDIO_SYSTEM_START=0
Now for an experienced user, no problem, you know exactly where to
find a configuration file for PulseAudio. For a new Linux user, yeah
tell me about it. I’ve been there when I started with Slackware back
late nineties.This guide shows a bunch of commands that you can use to find files containing specific text in Linux, namely Ubuntu, Debian, Mint, CentOS, Fedora and any Linux distro.
This guide will work for any Linux distributions, namely -
- Linux Mint
- Ubuntu
- Debian GNU/Linux
- Mageia / Mandriva
- Fedora
- openSUSE / SUSE Linux Enterprise
- Arch Linux
- CentOS / Red Hat Enterprise Linux
- PCLinuxOS
- Slackware Linux
- Puppy Linux
- Kali Linux (my distro )
Contents [hide]
- Find files containing specific text using grep command
- Find files containing specific text using grep command examples
- Find files containing specific text when you know the location
- Find files containing specific text when you don’t know the location
- Find files containing specific text with color output
- Find files containing specific text with filenames only
- Find files containing specific text and hide errors
- Find files containing specific text and ignore case
- Summary
Find files containing specific text using grep command
grep is a command-line utility for searching plain-text data sets for lines matching a regular expression. Grep was originally developed for the Unix operating system, but is available today for all Unix-like systems. Its name comes from the ed command g/re/p (globally search a regular expression and print), which has the same effect: doing a global search with the regular expression and printing all matching lines.grep command syntax
Syntax for grep command is simple:grep "text string to search” directory-pathOR
grep [option] "text string to search” directory-pathOR
grep -r "text string to search” directory-pathOR
grep -r -H "text string to search” directory-pathOR
egrep -R "word-1|word-2” directory-pathOR
egrep -w -R "word-1|word-2” directory-path
Find files containing specific text using grep command examples
In this example, we will search for'PULSEAUDIO_SYSTEM_START
‘ in all configuration files located in /etc directory.Now there’s a small problem, depending on your Linux, BSD or Unix distro, Find command can be slightly different (in terms of Syntaxes). So I will outline all possible combinations, you can just try one at a time to determine which one best suites you.
Find files containing specific text when you know the location
If you know the exact location and directory you’re after, then useroot@kali:~# grep "PULSEAUDIO_SYSTEM_START" /etc/default/pulseaudio PULSEAUDIO_SYSTEM_START=1 root@kali:~#
Read the rest of it here: How to find files containing specific text in Linux? Ubuntu, Debian, Mint, CentOS, Fedora and any Linux distro
No comments:
Post a Comment