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.

0
votes
0answers
17 views

Centralized application logging that combines matching log lines to a single output [migrated]

We have a solution where we have multiple data centers and per data center we have multiple servers with the same application. The application is handling stateless traffic and produces a lot of ...
1
vote
1answer
37 views

How to express `find`'s -writable and -readable tests, when they are not available?

Sometimes on old Linux systems, I experience that find doesn't support -writable and -readable tests, which test whether the file or directory is writable/readable resp. for the current user. Say, I ...
0
votes
2answers
43 views

Searching whole system for files with specific inode [duplicate]

I technically know how to do all these things, but combining it is problematic. Inode is saved in first line of text file (I can eventually read it directly from file), I need results saved to the ...
0
votes
2answers
39 views

How to find more than one space and replace it with one space?

I want to find repeated spaces (more than one) and replace them with one space. I tried: sed -e 's/ []+/ /g' myfile.txt > myfile2.txt This resulted in an empty file. Why? and how to achieve my ...
0
votes
1answer
17 views

How to express beginning and end of line in sed

I want to use sed to replace every '} that comes at the end of the line to "}. I wrote: sed -i -e "s/'}$/\"}$/g" But this replaces it to: "}$. What is wrong? How can I use regex in my sed to express ...
0
votes
1answer
29 views

How to search for a newline that is not preceeded by } and remove it

I want to use sed to search for line breaks that are not preceded by }. The regex for identifying theses cases is: [^}]$ . What I want to say: If the line ended without } then remove the new line. ...
0
votes
3answers
33 views

How to list all directory paths including a text?

I need to list all directory paths including a text which is part of thier sub-directories. For example, the text is "tpcc" and I have two paths including tpcc as following: /home/arghy/sampledir1/**...
1
vote
0answers
17 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
41 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
97 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 ...
-1
votes
2answers
66 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
97 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
84 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
32 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
265 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
37 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
358 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
31 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
362 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
32 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
29 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 ...
1
vote
1answer
50 views

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

I would like to somehow create links to files within the terminal from search results found when searching files. Same way you would click a hyperlink within the terminal, but in this case it would be ...
-4
votes
2answers
51 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
112 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
250 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
37 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
162 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
51 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
62 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
48 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
552 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
26 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
51 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
255 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
126 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
89 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
57 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
63 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
125 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
31 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
463 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
316 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
5k 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
491 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
486 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
544 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....