Questions tagged [search]

search is used for questions relating to searching through the contents of files. For searching for filenames using the locate command use the tag locate.

Filter by
Sorted by
Tagged with
1
vote
1answer
535 views

How to search for a pattern using grep?

I want to search a file to check for patterns like this: text1,text2,[1.2.3,3.4.5,6.7.8,etc] exist. The number of commas inside the square brackets is undefined. I tried the following command but it ...
2
votes
5answers
570 views

How to replace commas between brackets

I have text file that looks as follows: 12.com,128.15.8.6,TEXT1,no1,['128.15.8.6'] 23com,122.14.10.7,TEXT2,no2,['122.14.10.7'] 45.com,91.33.10.4,TEXT3,no3,['91.33.10.4'] 67.com,88.22.88.8,TEXT4,no4,['...
0
votes
4answers
40 views

How to replace the line with an exact matching of a string

I have a file with this content: dskldfsd.com domain domain.com sub.domain.com domain.main.com anythinghere I want to delete the line which contains the word domain. Using grep, this command ...
0
votes
2answers
28 views

search substring within a string and return next word

I have this string where I want to search for a keyword and then return the following word. "SELECT \"city\",\"temp_lo\",\"temp_hi\",\"date\" FROM schema_name.\"weather_7\"" I want to return "...
2
votes
4answers
612 views

How to extract columns before and after a string ocurrence

I have a text file. That looks like: www.ac.com has address 6.1.1.146 www.ac.com is an alias for ac.com. www.ac.com is an alias for ac.com. www.ba.net is an alias for www-bn.gs.ba.com. www-bn.gs.ba....
0
votes
2answers
92 views

How to query all lines in a file that are NOT equal or suffix of any name in another file

I have two files file1 and file2. The two files contain names. One name in each line. I want to query all names in file2 that are not equal to or a suffix of name in file1. Note that the prefix is ...
-1
votes
2answers
2k views

grep to extract lines that contains full domain names from a file [closed]

I have a large file that contains domain names in the form of: domain.com sub.domain.com sub.domain.co.uk domain.co.uk I want to extract main domain names (no sub domains) with top level domain name ...
1
vote
1answer
45 views

How can I search a string in a pdf file, and find the physical page number of each page where the string appears?

Given a PDF file, I would like to search for a string in its text, and I know pdfgrep can do that. I further would like to have the physical page number of each page where the string appears (as ...
-1
votes
1answer
69 views

Using egrep in /var/spool/postfix returns no results

My machine is using CentOS 7.1. I'm trying to search through all the files within /var/spool/postfix. The way I'm trying to achieve this is with: $ egrep -lir --include="*.*" "somemail@somedomain....
0
votes
1answer
99 views

Extracting lines that has match in the first column? [duplicate]

I have two files: file 1: a,txt1,v1 b,txt2,v2 c,txt3,v1 d,txt4,v2 file2: a,txt5,v2 b,txt6,v1 xc,txt7,v1 xd,txt8,v2 I want to refine the files. I only need the lines where the 1st column in file1 ...
0
votes
1answer
60 views

comparing 1st and 3rd column value in two files [closed]

I use Ubuntu 18 and have little experience with Linux commands. I have two files: file 1: a,txt1,v1 b,txt2,v2 c,txt3,v1 d,txt4,v2 file2: a,txt5,v2 b,txt6,v1 c,txt7,v1 d,txt8,v2 I want to print ...
1
vote
1answer
1k views

ripgrep: print only filenames matching pattern

Using ripgrep (rg), can I print only the filenames which match a given pattern? There are two separate things I'm trying to do: Match the pattern to the pathname itself (like ag -g pattern) Match ...
2
votes
2answers
127 views

Recursively grep through epub files

I tried the answers here, but without luck. find . -name "*.epub" -exec zipgrep pattern {} \; showed me "matched", but didn't give me the matching epub file back. Also, it returned huge blobs of ...
1
vote
1answer
80 views

How to Replace a string by another in a text file

I would like to replace a given string in a text file into by another, but with one extra detail. Example: If the file content's is : Library Hello1 =============== any text here version: 0.1 ------...
0
votes
4answers
276 views

Grep a pattern from a file and get that whole word, not just the pattern

List item I/P: abcd_Server1 CCDDomain defg_Server1 GGFDomain kdkhs_Server1 CCDDomain abce_Server1 CCDDomain dgdg_Server1 CCADomain dfdkhs_Server1 GGFDomain I need to search for the word "Domain" ...
1
vote
1answer
227 views

Escaping characters in command line search and replace [duplicate]

In Unix (running MacOS High Sierra), I've seen a few different search/replace (over several files) methods, e.g.: perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt or using sed or grep, etc. The ...
0
votes
1answer
93 views

How do I grep many files for many strings?

I have a file with many strings. For simplicity, assume it is newline-delimited, and that each string is made up of only contain alphanumeric ASCII characters and underscore. Now, I want to search a ...
1
vote
0answers
33 views

Index and search a directory

I have a directory tree containing many text-files. I would like to index the full-text of all these files (ignoring files with certain file-extensions), so that I can quickly search thorugh all of ...
0
votes
3answers
997 views

find user name through full name / gecos field?

Given a system where the user data comes from e.g. an OpenLDAP database and is not in the /etc/passwd file. Is it possible to search through the getent passwd database and look up the user id/name by ...
3
votes
2answers
84 views

How to pass a search pattern starting with $ to less on the command line

I just tried to pass a search pattern starting with $ to less: less +/'\$l' myfile.pl and I got There is no -l option ("less --help" for help) After reading the manual, I tried the alternate -p-...
1
vote
1answer
63 views

using grep to exclude results not matching specific query

I created a file (testimdb) with the following content: film: heat. year: 1995. director: michael mann. actors: al pacino, robert de niro, val kilmer film: the godfather part ii. year: 1974. ...
0
votes
2answers
635 views

How to search through and list files that do not contain specific phrase [duplicate]

I am running the same job on around 1000 input files. Around 10% of these will fail, but the only way of checking this is to scroll through the output files and check if it states completed without ...
0
votes
1answer
24 views

search which other python files invoke a class defined in an given pythonfile

There is a set of python files in a folder. One file includes a class definition, for instance Class DataGen: How can I know which python file in this folder use this Class? Are there any linux ...
-2
votes
2answers
143 views

How to organize installed programs in $HOME for shell to search for them when running them? [closed]

I have written or downloaded some programs ( bash scripts, python scripts, java programs, C programs) and placed them under /home/t/program_files/. For each program, I create a directory under the ...
2
votes
1answer
154 views

What limits Kate text editor search feature?

I am fairly new with Kate, started to use it, because it's search feature shows the number of occurrences found. But now I found a problem with search. It works fine for few line files (few hundreds) ...
0
votes
1answer
39 views

Search list of names and their values from a file to another files?

I have two .csv files. First file has one column of list of names and second file has sixty columns including names and their values in all columns. I am looking to search names from first file to ...
0
votes
1answer
13 views

Recent activity is not recorded or lost

A couple of days ago I started to experience issues with search/activity log on my Arch Linux system to be precise what I mean I'm using search tools like Synapse and basic one from Cairo Dock both of ...
1
vote
1answer
80 views

Does the search tracking and Amazon information sharing attributed to Ubuntu part of Debian?

I understand from Richard Stallman in this video, made probably in 2012/2013, that Ubuntu isn't 100% free by the GNU organization definition of Free Software, as according to Stallman there, it "spies"...
5
votes
4answers
1k views

How to list .txt files with specific content?

How do I list all .txt files with their full path that have a word 'Ubuntu' in them. Ignore non-text files. When comparing values you should ignore the case i.e. UBUNTU or ubuNtu or UbUnTu are treated ...
1
vote
1answer
158 views

Bash History Search

Is there a way to search bash history similar to zsh history search with percol? as shown at percol's github page. Specifically I want to be able to navigate the history interactively using a terminal ...
1
vote
1answer
95 views

How to exclude directory from find results if any of its parent directories contain a specific file

Im trying to use the find command to recursively search a directory tree and return all results with a directory matching a given name. find . -type d -name '<NAME>' I get a list of paths ...
1
vote
1answer
84 views

Improve search for files by pathnames with locate and grep pipeline

I often use the following pipeline of locate (from findutils) and grep to find files whose pathnames contain two words word1 and word2, without any specific order between each other: locate -i word1 |...
2
votes
1answer
92 views

Using a single command-line command, how would I search every text file in a database to find the 10 most used words?

This answered question explains how to search and sort a specific filename, but how would you accomplish this for an entire directory? I have 1 million text files I need to to search for the ten most ...
0
votes
1answer
70 views

Search for bash command

I want to search for bash commands in the bash itself. When I forget the name of a command I want a fast way to find it. For example "search for file" should suggest "find".
0
votes
1answer
25 views

How do I find a service whose name was changed; no alias

Here is the scenario: I do not have any prior services or programs, tripwire, etc., on my computer to tell me files or services that have changed. The integrity of a service, say ps, was changed so ...
1
vote
1answer
504 views

FTP, download files by wildcard search criteria

I need to download a series of files over ftp on a command line. The server I am downloading from has a folder structure which is like so: /path/to/file1/abcfile111def /path/to/file1/abcfile222def /...
-3
votes
2answers
483 views

Find and Extract Text inside Strings [closed]

I want to find text inside a string Pattern from a data file and extract them in a text list using shell or AppleScript. An example inside XML: node file="source_files/ (var1) .mp3" Another example ...
-2
votes
1answer
111 views

How to find the most popular word in the text in a text file through the linux terminal [duplicate]

How to find the most popular word in a text file through the linux terminal? Need to write a script
1
vote
0answers
291 views

Evolution full text searching

the full text searching in Evolution (e.g, in the body of the mails) is very slow. I see that, in each Mailbox setting, there is a checkbox to index the bodys of the message (cf http://i.imgur.com/...
0
votes
3answers
73 views

count country code in a file and save a file command or bash script

Situation: I would like to write bash script or a command which will count only country code in /var/log/mywebsite.log how many of them then save a file. I would like this script to check Linux time ...
1
vote
0answers
27 views

How to search email with Jämsä for Jämsän in Thunderbird?

Finnish language has many many endings, but I cannot search easily the base word, etc by Jämsä. For instance, searching Jämsä will not give Jämsän in the basic Thunderbird search. A basic regex ...
0
votes
1answer
111 views

How to make “incremental” replace in files with bash

I need to search files in directory with specific pattern (for example foobar) and replace them with foobarXXX, where XXX is a number. For example, there were two original file snt130.txt My ...
2
votes
4answers
1k views

vim regex search and replace

I'm trying to replace part of a string in a file For example I have a csv file. r1,col1,col2,35,000,col4,col5 r2,col1,col2,1,000,col4,col5 r3,col1,col2,325.33,col4,col5 r4,col1,col2,4,325.33,col4,...
0
votes
1answer
65 views

Is there a variant of “strings” that only matches null-terminated C strings?

I'm up against a situation that seems like it must already have an implemented solution somewhere, but I'm having a tough time finding one. I'm looking for something that functions more or less ...
1
vote
0answers
29 views

find all files containing all specified words [duplicate]

How can I use grep and/or find to find all files which have all of specfied words? So something like grep -R -words 'Quick', 'Lazy', 'Jumped' / would return all files on system with words Quick, ...
7
votes
1answer
819 views

ls *.csv --ignore=“*pattern*” returns files which contain “pattern”

Why does ls --ignore not ignoring the pattern? Looking at the below example: mkdir books cd books touch books_abby.csv touch books_karen.csv touch books_david.csv touch books_tom.csv This creates ...
0
votes
2answers
24 views

How to remove erroneous double quote in front of a string

cat group.txt ""BASEBALL" Flags: E,3 "Jason" "O" "Kim" "T" "Eric" "G" "Jenny" "B" "TENNIS" "Smith" "O" "Turner" "T" ""SOCCER" Flags: ...
9
votes
5answers
13k views

Why is the command “find | grep 'filename'” so much slower than “ find 'filename' ”?

I tried both commands and the command find | grep 'filename' is many many times slower than the simple find 'filename' command. What would be a proper explanation for this behavior?
0
votes
1answer
272 views

vim search and replace command to replace `(*,*)` with nothing

I'm reworking some Fortran code. I need to remove the pattern (*,*) using vim's search and replace function. The following does not work %s/\<(*,*)\>//gc %s/\<(*\,*)\>//gc %s/(*,*)//gc ...
4
votes
2answers
102 views

Extract Sub-Directory Path from Partially Known Directory

Lets say I've got the following directory structure: base/ | +-- app | | | +-- main | | | +-- sub | | | +-- first | | | | | +-- tib1.ear | ...