Stack Exchange Network

Stack Exchange network consists of 175 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.

1
vote
0answers
14 views

How do I enable listing of zsh commands as you type

on one of my machines while setting up zsh I seem to have accidentally enabled a pretty useful feature. when I search through command history it actually lists all the matching commands as I type. How ...
0
votes
1answer
29 views

How to capture two regex

In this command, I want to extract strings that are like *.com or *.net, where * is not a dot. I wrote this: grep -P -E '^[^.]+\.com$ |^[^.]+\.net$' example.csv I get this error: grep: conflicting ...
3
votes
3answers
77 views

Extract lines that have two or more dots

I need to extract (or count) the lines (in a file) that have two or more dots. The lines should not start with dot (it’s OK if they end with a dot), and there must not be two dots in a row (i.e., the ...
0
votes
2answers
53 views

Can we search in a pdf file for pages containing several words in no particular order?

I would like to search in a pdf file for all the pages, each containing several given words in no particular order. For example, I want to find all the pages which contain both "hello" and "world" in ...
0
votes
4answers
78 views

Removing lines whose first column is duplicated

I have a file where strings are separated by a special string (not a comma or delimiter) e.g. <vvv>. I want to check if all strings in the first field are unique. If duplicate rows for the same ...
0
votes
0answers
34 views

How to change the newline position [duplicate]

I have a file that contains string in each line. I used this file as an input in a program that reads them automatically. The program seem to not be able to read the strings correctly. I tried to ...
0
votes
2answers
72 views

How to pass multiple dynamic ! -path arguments to find

I have a file which contains a list of directories/files that I want to ignore when searching using find. It looks like this: .git .vim config .vimrc .bashrc This list is not exhaustive and can have ...
-3
votes
1answer
26 views

awk query for sequential replace a pattern

I found the below awk command to sequentially replace a particular line in a file, but i would like to know how this works. Input:- DS: 1 DS: 1 DS: 1 DS: 1 DS: 1 DS: 1 DS: 1 output:- DS: 1 DS: 2 ...
0
votes
1answer
85 views

find: './proc/1/map_files': Permission denied

I am inside a docker container build atop of the image alpine:3.6 and I am trying to find if a directory exists. I get te error, find: './proc/1/map_files': Permission denied This is the commands I ...
0
votes
1answer
32 views

How to extract the first column in a file with multi-character delimeter?

I have a file in which I use a string like <xxxxx> to separate the fields. This was a choice to avoid problems with the comma separated fields and other types of single characters due to the ...
4
votes
2answers
311 views

Searching for a string that contains the file name

I have a large set of files in a directory. The files contains arbitrary text. I want to search for the file name inside that particular file text. To clarify, I have file1.py.txt (yeas, two dots .py....
0
votes
0answers
22 views

Gnome Activities search does not find most files

When searching files from Gnome activities search only some files are found. I cannot find a clear pattern in which. All files and folders in home/ are found. Nothing in ~/Picture and ~/Documents are ...
3
votes
4answers
285 views

How to remove trailing forward slash

For each line in my file, if the line ends with / I want to remove it. How to do this? My attempt: sed -e "s/$\/$//" myfile.txt > myfile_noslash.txt Did not work.
-1
votes
1answer
26 views

Search for a string in lots files in a directory, if found, save the file name and line

I have several files, with different names. no specific format for them. But all are .txt. For example: example.txt flower.txt abc.com.txt They are in the same directory. I want to search for a ...
-1
votes
1answer
27 views

I want to pull specific data from a text file

I have a file called MemoryReport.txt . Somewhere in the middle of each line, it says Limit:. I would like for a script to copy only lines that says Limit:1 and exclude all others and print to a ...
0
votes
1answer
41 views

Search for files using terminal and open with preferred program when clicked?

I am not entirely sure if this is possible, but then again I am always surprised by the answers on here. With that said, Linux rules! And so do you guys! Alright, to be a little more clear, simply ...
-4
votes
2answers
50 views

Finding specific string in XML file and storing in another file [closed]

Text in input file is like this <title> <band height="21" isSplitAllowed="true" > <staticText> <reportElement x="1" y="1" ...
0
votes
2answers
59 views

Is there a way to search (grep/find) a specific word within multiple pdf files located on a specific drive?

I am trying to locate a client's pdf file that was saved on an external backup drive, which contains a little over 8000 pdf files and hundreds of folders. For example, if I want to search all pdf ...
0
votes
3answers
164 views

CLI utility to search and view/download YouTube videos

Is there a utility that can search YouTube from the command line, and then either view or download the search results according to user input? $ youtube-search madonna 1 Madonna - Hung Up (Official ...
-2
votes
1answer
35 views

Unable to search a string using more pager

I opened a file using the more pager,i was trying to find a string in this file using / as shown in the figure below,but it is saying that pattern not found even though the string i have searched is ...
0
votes
2answers
114 views

PDF reader with option to search multiple words at the time/match any of the words

Are there any PDF readers with advanced search options - searching several words at a time to be exact? Adobe has it by the name match any of the words as explained here. Regular (standard) search ...
1
vote
1answer
30 views

How to configure the “most” pager to highlight all matches on search?

I have been using the "most" pager for couple of years, but when searching and jumping and navigating between the matches ( with n and p ) the cursor is quite small (I barely notice it), so i'd like ...
2
votes
1answer
50 views

Tool for searching across branches and through history in a Git repository

I'm looking for a tool, or for suggestions towards a script, that would be able to search a Git repository for files based on both filenames and file contents (find/grep-like). It would need to be ...
2
votes
2answers
44 views

Search for three consecutive newlines?

I know that squeezing multiple blank lines can be done using cat -s (and squeezing all blank lines can be done using tr -s '\n'), but I'm curious how to search for this condition in a stream of input. ...
2
votes
1answer
527 views

How to grep '$$$$$'? [duplicate]

I want to check the absence of the following sequence of characters $$$$$ (i.e., 5 dollar signs) in a json file using grep as it has been used instead of comma to separate fields and I need to make ...
0
votes
0answers
24 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
48 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
155 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
90 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
70 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
52 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
58 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
94 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
27 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 ...
3
votes
4answers
398 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
249 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
3k views

Search for special characters using grep

I want to search for the lines that contains any of the following characters: : / / ? # [ ] @ ! $ & ' ( ) * + , ; = %
1
vote
0answers
31 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
416 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
327 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
39 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
396 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
76 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
1k 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
43 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
55 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
72 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
51 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
657 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 ...