Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
19 views

How to create a regex matching a custom string at the beginning of line while ignoring all preceding whitespaces via ag silversearcher?

Give an example file with the content: // find me val ignore me = "" // I should not be found // find me // find me I want to find all the lines with find me using ag silversearcher. ...
1
vote
0answers
45 views

How can I search a text file Google-style? [closed]

As you know, Google is very smart with searches, while the best search terminal tool I have ever seen just allows you to search with regexes. Is there a tool to search text more like a search engine? ...
1
vote
1answer
34 views

How to search for a folder or file in parent folders [duplicate]

I tried to search for a folder in its parent folders instead of its child sub-folders (usually any search bash command will do). I need to know whether any reverse alternative for any search commands ...
1
vote
2answers
34 views

AIX Unix - How to Find and Remove files created between date period, with starting and ending characters?

I'm using IBM AIX Unix and it's limited with command option. I want to implement below filter criteria using find and mtime (which works) option. I would like to remove the files listed with below ...
1
vote
4answers
50 views

RegEx for matching strings in 2nd and 5th columns using grep

I have a file (test.txt) that contains string such as: name1,6.5.8.12,specs1,version1,['66.55.89.12'] name2,19.13.13.159,specs2,version2,['13.13.173.59'; '14.19.232.42'] name3,141.101.196.40,specs3,...
0
votes
2answers
34 views

How to check if first column's string of file1 exist in the file2?

I have two files, file1.txt contains strings separated by commas: 1.1.1.1,string1,comment1 7.7.7.7,string3,comment3 2.2.2.2,string2,comment2 88.88.88.88,string4,comment4 999.999,999,999,string5,...
0
votes
2answers
57 views

How to extract string between the first occurrence of : and a colon

I have a long file that I need to reprocess for entering it into database. The file's data are in this format: Error for: 111.222.55.1,[ZXX: Error message] some text (_xxx.c:833) Error for: 198.243....
0
votes
1answer
43 views

Find files that contain filler (0x00)

My qbitorrent was set to preallocate files. After a crash it lost a lot of torrents many of which were incomplete. (I purged it afterward, using deluge now) I have a directory containing 1000s of ...
1
vote
0answers
18 views

Configuring default output for Aptitude package search

In most flavors of Linux that I've used, the output for apt search does not include the current state display but in Linux Mint (Sylvia) it is displaying and I would like to remove it because it ...
0
votes
0answers
36 views

shell script to scan ebs volumes for a text

I have a requirement, where I need to search the attached aws multiple ebs volumes on a Linux Ec2 instances for certain text. For example below are the disk attached. > lsblk NAME MAJ:MIN RM ...
3
votes
4answers
293 views

Extract addresses separated by semicolon and print each address in a line

I have a file with the following input. The numbers separated by dots represents addresses. Any number in address can be one or more digits as follows: [112.112.112.112;3.3.3.3;44.44.44.44] [6.6.6.6;...
0
votes
2answers
64 views

Searching for URLs with subdomains using grep

I have a file with content similar to: mail.google.com srv1.mail.google.com google.com facebook.com yahoo.com tt.twitter.com I want to search for lines with subdomains. I used this command: grep -e ...
6
votes
3answers
1k views

Search for special characters using grep

I want to search for the lines that contains any of the following characters: : / / ? # [ ] @ ! $ & ' ( ) * + , ; = % I am familiar with grep. But with this set of characters, it is a bit tricky ...
1
vote
0answers
29 views

Is there a tool for searching keywords super fast in many pdfs files?

I have a bunch of technical books, and I have been using pdfgrep for a while, but it takes substantial amount of time for searching all. can somebody recommend me of a cli tool for searching in pdf ...
1
vote
1answer
99 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
85 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
33 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
25 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
213 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
56 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
560 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 ...
0
votes
1answer
33 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
34 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
46 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
41 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
291 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 ...
0
votes
0answers
26 views

ag: search ignored files but not binary files

In ag (The Silver Searcher), how can I search through all files, including ignored files, but excluding binary files? The only option which includes ignored files seems to pull in binary files also: ...
2
votes
2answers
77 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
90 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
84 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
52 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 ...
0
votes
0answers
24 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
487 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
50 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
43 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
56 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
23 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
111 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
98 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
63 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
882 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
119 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
74 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
75 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
89 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
51 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
24 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 ...