How to search for files containing specific word?
How to search for files containing specific word?
command-line
add a comment |
How to search for files containing specific word?
command-line
5
Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?
– dr_willis
May 2 '11 at 13:39
add a comment |
How to search for files containing specific word?
command-line
How to search for files containing specific word?
command-line
command-line
asked May 2 '11 at 12:27
UAdapterUAdapter
5,312346693
5,312346693
5
Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?
– dr_willis
May 2 '11 at 13:39
add a comment |
5
Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?
– dr_willis
May 2 '11 at 13:39
5
5
Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?
– dr_willis
May 2 '11 at 13:39
Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?
– dr_willis
May 2 '11 at 13:39
add a comment |
4 Answers
4
active
oldest
votes
With command line you have several options. The 3 I use the most are...
locate {part_of_word}
This assumes your locate-database is up to date but you can update this manually with:
sudo updatedb
grep
as explained by dr_willis.
One remark:-R
aftergrep
also searched within directories.
Example:
cd
grep -R {something_to_look_for} {where_to_look_in}
find . -name '*{part_of_word}*' -print
Where .
is the directory where you are at the moment and *
is a wildcard.
Oh and you can also combine these. Example:
locate {something}|grep {some_part_of_something}|more
If I recall correctly: locate
is the fastest one (assuming your database is up to date) and find
is the slowest one. And grep
is the most complex but also the most versatile one of these since you can use regexes.
add a comment |
grep -R "what" "where"
example:
grep -R hello /home
add a comment |
The grep command is commonly used for this.
grep PATTERN filename
and grep can do some very complex searching.
willis@Cow:~$ grep --help
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c
3
or you can do "rgrep word ." to recursively search every file and subdirectory for "word"
– Jeremy Bicha
May 2 '11 at 12:48
add a comment |
You can use grep
to list the files containing word
in the given directory
:
grep -Ril word directory
Here:
* -R
recursively search files in sub-directories.
* -i
ignore text case
* -l
show file names instead of file contents portions. (note: -L
shows file names that do not contain the word).
use man grep
to get all the options
3
Just so you know:-i
performs a case-insensitive search.
– David Foerster
Feb 11 '16 at 10:21
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f39200%2fhow-to-search-for-files-containing-specific-word%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
With command line you have several options. The 3 I use the most are...
locate {part_of_word}
This assumes your locate-database is up to date but you can update this manually with:
sudo updatedb
grep
as explained by dr_willis.
One remark:-R
aftergrep
also searched within directories.
Example:
cd
grep -R {something_to_look_for} {where_to_look_in}
find . -name '*{part_of_word}*' -print
Where .
is the directory where you are at the moment and *
is a wildcard.
Oh and you can also combine these. Example:
locate {something}|grep {some_part_of_something}|more
If I recall correctly: locate
is the fastest one (assuming your database is up to date) and find
is the slowest one. And grep
is the most complex but also the most versatile one of these since you can use regexes.
add a comment |
With command line you have several options. The 3 I use the most are...
locate {part_of_word}
This assumes your locate-database is up to date but you can update this manually with:
sudo updatedb
grep
as explained by dr_willis.
One remark:-R
aftergrep
also searched within directories.
Example:
cd
grep -R {something_to_look_for} {where_to_look_in}
find . -name '*{part_of_word}*' -print
Where .
is the directory where you are at the moment and *
is a wildcard.
Oh and you can also combine these. Example:
locate {something}|grep {some_part_of_something}|more
If I recall correctly: locate
is the fastest one (assuming your database is up to date) and find
is the slowest one. And grep
is the most complex but also the most versatile one of these since you can use regexes.
add a comment |
With command line you have several options. The 3 I use the most are...
locate {part_of_word}
This assumes your locate-database is up to date but you can update this manually with:
sudo updatedb
grep
as explained by dr_willis.
One remark:-R
aftergrep
also searched within directories.
Example:
cd
grep -R {something_to_look_for} {where_to_look_in}
find . -name '*{part_of_word}*' -print
Where .
is the directory where you are at the moment and *
is a wildcard.
Oh and you can also combine these. Example:
locate {something}|grep {some_part_of_something}|more
If I recall correctly: locate
is the fastest one (assuming your database is up to date) and find
is the slowest one. And grep
is the most complex but also the most versatile one of these since you can use regexes.
With command line you have several options. The 3 I use the most are...
locate {part_of_word}
This assumes your locate-database is up to date but you can update this manually with:
sudo updatedb
grep
as explained by dr_willis.
One remark:-R
aftergrep
also searched within directories.
Example:
cd
grep -R {something_to_look_for} {where_to_look_in}
find . -name '*{part_of_word}*' -print
Where .
is the directory where you are at the moment and *
is a wildcard.
Oh and you can also combine these. Example:
locate {something}|grep {some_part_of_something}|more
If I recall correctly: locate
is the fastest one (assuming your database is up to date) and find
is the slowest one. And grep
is the most complex but also the most versatile one of these since you can use regexes.
edited Aug 21 '15 at 18:04
Fabby
26.9k1360161
26.9k1360161
answered May 2 '11 at 12:48
RinzwindRinzwind
207k28398528
207k28398528
add a comment |
add a comment |
grep -R "what" "where"
example:
grep -R hello /home
add a comment |
grep -R "what" "where"
example:
grep -R hello /home
add a comment |
grep -R "what" "where"
example:
grep -R hello /home
grep -R "what" "where"
example:
grep -R hello /home
answered May 2 '11 at 13:21
DemonWareXTDemonWareXT
90167
90167
add a comment |
add a comment |
The grep command is commonly used for this.
grep PATTERN filename
and grep can do some very complex searching.
willis@Cow:~$ grep --help
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c
3
or you can do "rgrep word ." to recursively search every file and subdirectory for "word"
– Jeremy Bicha
May 2 '11 at 12:48
add a comment |
The grep command is commonly used for this.
grep PATTERN filename
and grep can do some very complex searching.
willis@Cow:~$ grep --help
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c
3
or you can do "rgrep word ." to recursively search every file and subdirectory for "word"
– Jeremy Bicha
May 2 '11 at 12:48
add a comment |
The grep command is commonly used for this.
grep PATTERN filename
and grep can do some very complex searching.
willis@Cow:~$ grep --help
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c
The grep command is commonly used for this.
grep PATTERN filename
and grep can do some very complex searching.
willis@Cow:~$ grep --help
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c
answered May 2 '11 at 12:33
dr_willisdr_willis
3771211
3771211
3
or you can do "rgrep word ." to recursively search every file and subdirectory for "word"
– Jeremy Bicha
May 2 '11 at 12:48
add a comment |
3
or you can do "rgrep word ." to recursively search every file and subdirectory for "word"
– Jeremy Bicha
May 2 '11 at 12:48
3
3
or you can do "rgrep word ." to recursively search every file and subdirectory for "word"
– Jeremy Bicha
May 2 '11 at 12:48
or you can do "rgrep word ." to recursively search every file and subdirectory for "word"
– Jeremy Bicha
May 2 '11 at 12:48
add a comment |
You can use grep
to list the files containing word
in the given directory
:
grep -Ril word directory
Here:
* -R
recursively search files in sub-directories.
* -i
ignore text case
* -l
show file names instead of file contents portions. (note: -L
shows file names that do not contain the word).
use man grep
to get all the options
3
Just so you know:-i
performs a case-insensitive search.
– David Foerster
Feb 11 '16 at 10:21
add a comment |
You can use grep
to list the files containing word
in the given directory
:
grep -Ril word directory
Here:
* -R
recursively search files in sub-directories.
* -i
ignore text case
* -l
show file names instead of file contents portions. (note: -L
shows file names that do not contain the word).
use man grep
to get all the options
3
Just so you know:-i
performs a case-insensitive search.
– David Foerster
Feb 11 '16 at 10:21
add a comment |
You can use grep
to list the files containing word
in the given directory
:
grep -Ril word directory
Here:
* -R
recursively search files in sub-directories.
* -i
ignore text case
* -l
show file names instead of file contents portions. (note: -L
shows file names that do not contain the word).
use man grep
to get all the options
You can use grep
to list the files containing word
in the given directory
:
grep -Ril word directory
Here:
* -R
recursively search files in sub-directories.
* -i
ignore text case
* -l
show file names instead of file contents portions. (note: -L
shows file names that do not contain the word).
use man grep
to get all the options
edited Feb 15 at 2:41
answered Apr 29 '15 at 17:47
chandanchandan
181119
181119
3
Just so you know:-i
performs a case-insensitive search.
– David Foerster
Feb 11 '16 at 10:21
add a comment |
3
Just so you know:-i
performs a case-insensitive search.
– David Foerster
Feb 11 '16 at 10:21
3
3
Just so you know:
-i
performs a case-insensitive search.– David Foerster
Feb 11 '16 at 10:21
Just so you know:
-i
performs a case-insensitive search.– David Foerster
Feb 11 '16 at 10:21
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f39200%2fhow-to-search-for-files-containing-specific-word%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?
– dr_willis
May 2 '11 at 13:39