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
0
votes
0answers
21 views

Can't Find Installed Software in Ubuntu Search

I have installed some software from downloaded files (not from a repo) but I would like to be able to find them through the Ubuntu search engine in order to have them available in my task bar. For ...
0
votes
2answers
52 views

How can I search date format in vi?

I want to search date format like 2019-07-12 11:22:33. but, in vi mode, :/2019-07-12 11:22:33 is not executed by white space. how can I search 2019-07-12 11:22:33? (other format is not pretty)
0
votes
1answer
27 views

How can I search terminal output?

Say I type git help to learn about the merge command. I don't want to read all the output just the lines that contain merge and their surrounding lines. I thought this would be a common question but ...
0
votes
2answers
63 views

Find searches only for the first matching entry

I have to find all directory paths with specific subfolders. The search pattern is as follows: find /foo/*/searched_folder/bar -maxdepth 0 -type d ̶I̶t̶'̶s̶ ̶w̶o̶r̶k̶i̶n̶g̶ ̶p̶r̶e̶t̶t̶y̶ ̶w̶e̶l̶l̶ ...
0
votes
1answer
24 views

Use reverse i search to cycle through only commands matching pattern

The contents of the command history file using history | less is: 555 ls 556 ls -a 557 echo "hello" 558 echo "hello again" 559 cd 560 pwd 561 echo "hello hello" 562 ls 563 echo "hello hello hello" ...
0
votes
4answers
46 views

Use grep to search for words beginning with non-word characters

The contents of the file testing.txt are: ls -a cmake --verbose verbose I want to use grep to look through this file and find only the word beginning with "--" i.e. the word "--verbose" However ...
52
votes
10answers
45k views

How can I search history with text already entered at the prompt in zsh?

In zsh, I know that I can search history with Ctrl+r. However, oftentimes I start to type a command directly at the prompt, but then realize I should be searching history. When I hit Ctrl+r, it brings ...
1
vote
1answer
38 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 ...
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 ...
0
votes
2answers
365 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 ...
0
votes
2answers
45 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
56 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
23 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 ...
1
vote
1answer
51 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 ...
0
votes
1answer
30 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. ...
1
vote
2answers
3k views

How do you search and replace multiple lines in KDE Kate?

how do you replace multiple lines of code in Kate? The following is the original text: <div id="image"> <br style="clear: left"/> <br style="clear: left"/> <br style="clear: ...
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 | ...
0
votes
3answers
35 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/**...
7
votes
1answer
822 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 ...
1
vote
0answers
22 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 ...
3
votes
3answers
119 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
4answers
117 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 ...
5
votes
4answers
6k views

Print only the Nth line before each line that matches a pattern

I'm trying to print only the <N>th line before a search pattern. grep -B<N> prints all the <N> lines before the search pattern. I saw the awk code here that can print only the <N&...
0
votes
1answer
44 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 ...
1
vote
1answer
794 views

How to search “info” page for keyword

I'm currently looking through the "info" page for "ls" command and I want to find all relevant sections that contain the keyword "-l". But I'm not sure how to search for keywords and how to move ...
-1
votes
2answers
68 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 ...
3
votes
2answers
550 views

Faster search than find

Is there a way to find things faster than find . I am/was doing :- $sudo find / -perm +4000 But it takes ages to find the required info. and I know that most of the files which would that specific ...
128
votes
14answers
92k views

How can I grep in PDF files?

Is there a way to search pdf files using the power of grep, without converting to text first in Ubuntu?
2
votes
6answers
567 views

Searching strings on files

I've got a bunch on strings which I need to find in a couple of files, for example: string1 string2 stringn file1.txt file2.txt filen.txt Is there an (easy) way to do that in bash? I need to know, ...
31
votes
9answers
3k views

Reading and searching long man pages

I finally got fed up when wanting to read about bash's read and it's -s option with man bash. I found the right spot eventually (around line 4500), but it was a frustrating as usual, since both /read ...
0
votes
0answers
35 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 ...
23
votes
3answers
14k views

Search for mail content with Mutt

Is it possible in Mutt to search for specific mail content using built-in functionality? Or, as a last resort, how can I configure grep to be used in Mutt? The documentation only mentions the search ...
37
votes
7answers
9k views

Command-line-friendly full-text indexing?

Is there such a thing as a full-text indexing engine, that can be queried from the command line and ideally wouldn't require using a gui at all ? I'm especially interested in indexing my ebooks and ...
0
votes
2answers
97 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 ...
8
votes
4answers
7k views

grep how to suppress display of non-matched file?

I am trying to find files containing a specific word using grep. There are many files in the directory (> 500) Command I run $ grep 'delete' * Output validate_data_stage1:0 validate_data_stage2:0 ...
1
vote
3answers
734 views

How to search and replace a string with newlines on commandline in a file

I want to replace all occurrences of a text string in a textfile on command line on CentOS 7.2. Search-string: ).\nPORT Replacement-string: ). \n0 closed ports\nPORT I know, this can be achieved ...
-3
votes
1answer
39 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 ...
22
votes
3answers
96k views

Searching for a string on multiple zip files

I am working on SunOS 5.10. I have a folder that contains about 200 zip files. Each zip file contains only one text file in it. I would like to search for a specific string in all the text files in ...
0
votes
1answer
355 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
38 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 ...
24
votes
7answers
8k views

How to replace current word under cursor in Emacs

How do I replace current word under cursor in Emacs? I know that I can use query-replace or replace-string but every time I do so I have to type entire string to be replaced, this is just annoying. ...
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: : / / ? # [ ] @ ! $ & ' ( ) * + , ; = %
4
votes
2answers
377 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
38 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
411 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
34 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
30 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 ...
126
votes
4answers
53k views

locate vs find: usage, pros and cons of each other

In Linux and Unix systems there are two common search commands: locate and find. What are the pros and cons of each? When one have benefits over the other?
-4
votes
2answers
55 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
155 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 ...