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
2
votes
2answers
73 views

Move the cursor directly to `<keyword>` in a long command line

I often find myself in a long command-line, where it can be a pain to navigate to a specific location in the middle by means of Left-Arrow, Right-Arrow, Alt+B, Alt+F etc. I know that using tmux, I ...
3
votes
2answers
29 views

less: search, but ignoring special characters

I'm trying to view large log files. I have a complex shell script that will take a log file and run it through a tangle of text-mangling commands to insert formatting and colouring, and pipe the ...
3
votes
3answers
77 views

How to find character locations of a string in a file?

I need to search for a string (a sequence of characters) in a file with a certain encoding, typically utf8, but return the character offsets (not byte offsets) of the results. So this is a search ...
0
votes
0answers
30 views

Search all disk images for a file name?

When backing up many SD card images onto a large HDD, I am not sure whether one SD card is already included or not. I would like to search all the images for a file name saved on that card, e.g. ...
0
votes
0answers
22 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
56 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
35 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
65 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
28 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
50 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 ...
1
vote
1answer
43 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
46 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
80 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
25 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
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
3answers
39 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
23 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
48 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
143 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
72 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
137 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
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 ...
0
votes
2answers
100 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
53 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
453 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
41 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
381 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
46 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
483 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
35 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
31 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
53 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
62 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
194 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
452 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
221 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
70 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 ...
3
votes
1answer
80 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
64 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
566 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
53 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
329 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
197 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
134 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
66 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
69 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
170 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
37 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 ...