LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-01-2018, 06:45 AM   #1
grumpyskeptic
Member
 
Registered: Apr 2016
Posts: 483

Rep: Reputation: Disabled
How to search through contents of .csv and .txt files in folders and sub-folders


I have Linux Mint 17.3 Rosa Cinnamon

I have a lot of .csv and some txt files in a hierarchy of folders.

I want to search through the contents of all the files for a particular word.

What is the easiest way to do this please?

Is there some software available (preferably with a GUI) or are there console commands I should use?

Note that I want to search inside the files, not find files.

Thanks
 
Old 03-01-2018, 07:00 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I use grep for this
Code:
grep -rli 'some words' /path/to/directory

Last edited by keefaz; 03-01-2018 at 07:10 AM. Reason: removed -n option (doesn't work combined with -l)
 
Old 03-01-2018, 07:03 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,885
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
I personally use the find command and the -exec option to perform a grep. That's what is easiest, for me. If you want a GUI option, I do not know if the File Manager on most desktops works similar to the search option in Windows where it can find in files.
Code:
$ find . -name "*.csv" -exec grep word {} /dev/null \;
 
Old 03-01-2018, 07:13 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,161

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
Quote:
Originally Posted by rtmistler View Post
I personally use the find command and the -exec option to perform a grep.
You are one twisted puppy.

Oops - did I just say that or only think it ? ....

grep as above is good, most of the bigger/popular DEs these days seem to include a (supposedly) background indexer that should do the job from a GUI file manager.
 
Old 03-01-2018, 08:52 AM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
find would eliminate having to search through every stinking file in a directory and limit it to just the ones you tell it to search, so yeah I can its its purpose.


Code:
find blah blah | grep foo bar
never tried that mind you.
Code:
grep -rwn /path -e search pattern
that's the one I use.

just cvs and some txt files or text files?
Code:
find /path -name "*.cvs" -o -name "*.txt" -exec grep word {} /dev/null \;
should work

Last edited by BW-userx; 03-01-2018 at 09:07 AM.
 
Old 03-01-2018, 09:15 AM   #6
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
I can't speak for 17.3, but for 18.x, if you click on the Mint menu button and type in "search" then you'll see "Search for Files" appear.

Click on that to launch it (it's actually Gnome Search Tool), click on "Select more options" and fill in the "Contains the text" field.

Select the folder to look in (it also looks in subfolders) and you're good to go.
 
Old 03-04-2018, 05:57 AM   #7
grumpyskeptic
Member
 
Registered: Apr 2016
Posts: 483

Original Poster
Rep: Reputation: Disabled
Thank you hydrurga, that is not already in my 17.3 version of Linux Mint, but can be found in the Software Manager as "gnome-search-tool" and installed. It can search within files as you say.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script to compare folders,Sub-Folders and Sub-Sub-Folders unix_72427 Programming 8 08-08-2012 02:51 PM
Copy the contents of a txt file to other txt files (with similar names) by cp command Aquarius_Girl Linux - Newbie 7 07-03-2010 12:54 AM
find -exec command to recursively delete files and folders in folders with X name Joan Murt Linux - Newbie 2 07-08-2009 04:35 PM
Contents of folders not showing up tardigrade Linux - General 1 02-02-2009 06:34 AM
Samba can create new files and folders but access denied in any new folders k.king Linux - Networking 2 01-15-2006 06:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration