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
4 answers
68 views

Grep, but for binaries

I've got a fragment of an image file produced by data-recovery software. I suspect the complete original is somewhere on my home fileserver. If this were a fragment of a text file, I could just grab ...
  • 3,944
0 votes
0 answers
41 views

searching 1337x.to on command line

Is there a way to search say 1337x.to or any torrent site via cli. I do know qbittorrent or rather qbittorrent-nox recently got a way to parse RSS feeds but dunno if there is something that can do the ...
  • 11.7k
0 votes
1 answer
96 views

How do I find and replace something AFTER a specific term in a terminal output

I need to run blkid and copy a specific UUID after a specific known partition name. Then, I need to paste this into an exists config file, replacing a UUID that it's already there (parent_device_uuid)....
-3 votes
1 answer
95 views

How to set up local Windows directory in WSL correctly?

I ran this script in Windows Subsystem for Linux at the command line. I wanted to search for the latest files but I got the error message "no such file or directory", and so I wonder how do ...
0 votes
0 answers
88 views

nslookup is not recursing through search domains in /etc/resolv.conf, but ping is

I'm trying to understand why multiple search domains do not work with nslookup in Ubuntu 22.04 (or ostensibly any other distro), but appear to work as expected when using ping. Let me explain. A DNS ...
  • 117
0 votes
0 answers
22 views

digikam album shows some photos are missing, can it display all missing images?

I was working on an album (a month's worth of photos) in digikam and noticed that some images displayed an icon to say that they were missing from the expected location. Is it possible to search and ...
0 votes
1 answer
159 views

ansible lineinfile module to match variable_value

how can one possibly match value of a variable through regex parameter in lineinfile module? - name: emptyline before search lineinfile: dest: ~/file insertbefore: '^{{ search_text }}$' ...
  • 1,843
0 votes
1 answer
44 views

uncomment the line upon search string while ignoring case in a file

Below is my cron file entries: #Ansible: test2 */15 * * * * ansible-playbook /web/playbooks/automation/detect401MORTEN/va_action.yml | tee -a /web/playbooks/automation/detect401MORTEN/cron.out # #...
  • 427
0 votes
1 answer
53 views

How to get one line above the enabled crontab entry

I have the below crontab entries $ crontab -l #Cron to auto restart app1 #Ansible: test1 #*/15 * * * * ansible-playbook /web/playbooks/automation/va_action.yml #Cron to auto restart app7 #Ansible: ...
  • 427
0 votes
4 answers
90 views

Given a filepath, how do I find every copy of that file?

I know of programs such as rdfind or fdupes. They solve a similar but more complicated problem. Given a file path and a directory, I want to search that directory recursively for every copy of that ...
  • 413
0 votes
2 answers
116 views

search of .xml files without certain tag through mac os terminal

I would appreciate having your advice on the below. Having a folder name "ABC" with thousands of .xml files inside. The core structure of XMLs is the same: <product abcd…> <...
1 vote
1 answer
247 views

Search Hexadecimal Sequence from start position until some defined number of bytes of huge Binary File (grep, sed)

In my Mac, I have this binary 'file' /dev/disk0s1 with 512GB (Really is a drive or volume according to AFPS of macOS) and I need to find this Hexadecimal Sequence 0x41, 0x50, 0x53, 0x42 for APSB (in ...
3 votes
1 answer
293 views

used awk to search by unicode in txt file

How i can used awk to search in txt file by unicode like : u+064C u+064D and please how i count results and print the number in first line.
  • 33
2 votes
2 answers
70 views

search in txt file and every result in new file

For context, this is a follow-up on search in txt file then print in new txt file with a few extra complications. I have 2 txt files the first one is data.txt file which contains over 2000 lines, the ...
  • 23
0 votes
2 answers
84 views

search in txt file then print in new txt file

i have txt file which containt over 1000 line, the data in it like: alpha hmld ahge 573 otndgd fhj 29 fidnt ank 1962 beta jdkrs 2 adny 14 urmekhjf 6893 ... how i can search and print (in new txt ...
  • 23
0 votes
2 answers
41 views

script to print word at specific location at specific line into a new file

below is the file from which the data should be copied from a specific line and specific location CP I ({010010010010010010010010010010}000 000) 234764-CTS_fsdfs_a_inv_33ghf/ZN --- I ...
  • 1
0 votes
1 answer
160 views

How to find a property file matching a pattern in a group of JAR files?

I'm using bash shell. I have a group of JAR files in directories at different levels > find . -name "*.jar" /tmp/jars/META-INF/lib/jackson-datatype-jdk8.jar /tmp/jars/lib/my-custom.jar .....
  • 2,164
1 vote
2 answers
620 views

How can I search only git tracked files with a specific file extension?

I'd like to search all git tracked files that 1. has an .hs file extension and 2. contain the word import in any lines. I've tried to use git ls-files -z | xargs -0 rg -g '*.hs' "import" ...
0 votes
0 answers
26 views

Get a list of the last opened text and odt files

can I retrieve a list of the last opened textfiles (well, I have some textfiles without ending .txt which is probably not possible to retrieve. Some do have a .txt ending though) Also I need the last ...
  • 365
0 votes
2 answers
371 views

Linux search file with given name containing string recursively

From Linux shell, Let's say I'm in directory /dir and I want to find, recursively in all subfolders, all the files which contain in the name the string name_string and, inside, the string ...
0 votes
0 answers
56 views

How can I reverse backward-search to forwards-search and jump to next item with single type of C-s

I am using solution in unable to forward search Bash history similarly as with CTRL-r. To search backward in the history for a particular string, type C-r. Typing C-s searches forward through the ...
  • 440
1 vote
2 answers
363 views

awk get column value from file 2 for file 1 if value matches in 2 columns [duplicate]

I have 2 files, trying to set column value that is taken from file2 into file1 when their columns match file1: signup||20200620|A3332|en|LA||ACTIVE signup||20200620|B4443|en|CA|66001|ACTIVE signup||...
  • 1,843
0 votes
2 answers
377 views

replace text in specific field with variables from loop

I have a huge file to parse & need to search and replace text but in specific fields, sharing a small sample for reference named dest. first row is header for reference. cat dest ID|NAME|COMPANY|...
  • 1,843
-1 votes
2 answers
513 views

awk no print if value from file1 not match value in file2

file1: G A 4 H B 3 I C 2 J D 1 file2: M H 6 N H 5 O K 4 P J 3 Q I 2 R I 1 S G 0 T L 1 Desired: M H 6 N H 5 P J 3 Q I 2 R I 1 S G 0 print only rows where $2 from file2 matches $1 from file1 I'm ...
  • 1,843
-1 votes
2 answers
91 views

awk bring same field value from file1 and set in file2 [closed]

File1 (parent) 2210 1110 Earth 2211 1111 Marse 2212 1112 Saturn 2213 1113 Pluto File2 (child) 3310 2210 Earth 3311 2210 Space 3312 2211 Mars 3313 2211 Space 3314 2212 Saturn 3315 2212 Space 3316 ...
  • 1,843
2 votes
1 answer
89 views

Global search + replace, but only in cases where a test passes

I want to do a global search and replace on a directory of files. There are various ways to do this (many editors, sed+find), but I have an extra requirement. I want, for each possible replacement to ...
-1 votes
3 answers
256 views

awk print only modified lines

I have file like this d1000 1000 d1001 100 d1002 10 d1003 1 I want to modify second column where length is not equal 4. But I want to print only lines that are modified, so original text in column 2 ...
  • 1,843
0 votes
1 answer
394 views

Where does "apt list" search?

apt list can list all packages available, does apt search in some database or file in some directory? apt list --installed can list all installed packages, where does apt search then?
  • 285
1 vote
0 answers
40 views

How to find the PHP file which prints an HTML element with a certain selector?

I store my MediaWiki 1.36.1 website with Skin:Timeless on NameCheap with a shared hosting environment with Cpanel file manager and SSH shell access. In my website, there is a certain footer element ...
-1 votes
1 answer
47 views

Search & replace for a string separated by whitespace upon substring match found

Below is a sample file content: cat sample.txt -server -XX:+UseParallelGC -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+AggressiveHeap -XX:+PrintHeapAtGC -Djava.util.logging.FileHandler....
  • 427
0 votes
0 answers
78 views

Linux command for searching a log

I’m trying to search an Apache log for a specific error, displaying the lines descending with counts. What would be the best way to accomplish this?
  • 1
0 votes
2 answers
1k views

How can I see the line number of a searched text?

Suppose, I have a text file named output.txt which contains 1.46 million rows of data. I want to search a text 27QL in the file. If the text exists, Linux should return the line number. How can I do ...
0 votes
0 answers
451 views

Searching strings in raw disk image

I am currently writing a tool that should scan a readonly raw disk image for a a given pattern. The task is to get the byte offset of the match. I am able to find simple text documents with grep -a -o ...
0 votes
4 answers
162 views

Search and Remove Lines of Code from all files

I need help and need to search for and remove a 3 line bit of code from all files in a directory. Code is: if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) )...
0 votes
1 answer
368 views

Why is this mv command trying to write to a directory?

I'm using this search and replace string; find . -name 'xna*jpg' -exec bash -c ' mv $0 ${0/\ (2018_05_28 14_04_27 UTC)/}' {} \; So that it will replace "xna (2018_05_28 14_04_27 UTC).jpg" ...
2 votes
3 answers
742 views

Replace dynamic word using sed command

I have a requirement where we need to replace a word in a file which can be different everytime I execute the script, the content of the file is class DynamicContentToReplace > Something Here I ...
0 votes
1 answer
94 views

How do I configure ag so that it will also search for files beginning with a "."?

I'm using ag v 2.2. How do I configure ag so that it will search for files beginning with a "." in addition to all other files? I'm noticing I have a file like so $ cat client/.env....
  • 2,164
1 vote
2 answers
202 views

How to have "apt search" give one-line summaries?

apt-cache gives one line summaries: $ apt-cache search conway golly - Game of Life simulator using hashlife algorithm libclass-delegator-perl - Perl module for a simple and fast object-oriented ...
  • 21
4 votes
2 answers
682 views

Search PDF files with more than 100 pages and moving them into directory in UNIX/LINUX terminal

I'm trying to search for PDF files that have more than 100 pages and then moving them into a specific directory in the UNIX/LINUX terminal. Something a bit like this: find . -name '*.pdf' -pagenumber&...
  • 143
5 votes
1 answer
407 views

Using anchor ^ pattern when using less / search command

When navigating through Linux man pages, sometimes you need to query the meaning of flags like -p or -al in the man pages. The default text reader for man pages is less and I'm trying to use the / ...
  • 319
0 votes
1 answer
265 views

How can I make pacman search look better?

Currently I am using Arch. Pacman is a great package manager but can I make pacman search look better (pacman -Ss). For example if I search for a package it gives me result lik this: extra/foomatic-db-...
0 votes
1 answer
639 views

Is there a way to search in only properties file when using grep?

I am normally searching like this grep -rnws '/path/to/directory/' -e 'JMSAppender' However this does display all jar files and class files where it might be used. I need to check only inside log4j ...
0 votes
1 answer
80 views

Search for all videos created on a Saturday

I am using Linux Mint. There are several years worth of files and folders scattered everywhere. My goal is to find a way to search my entire hard drive for any video files that were created on a ...
0 votes
1 answer
105 views

Is it possible to integrate pdfgrep into nemo search?

I often find myself looking for PDF documents. Luckily, I found pdfgrep that really does a great job at finding PDF documents by content. Following command lets me search for documents that have my ...
6 votes
3 answers
2k views

Finding duplicate files with same filename AND exact same size

I have a huge songs folder with a messy structure and files duplicated in multiple folders. I need a recommendation for a tool or a script that can find and remove duplicates with simple two matches: ...
3 votes
2 answers
3k views

How to search for a string in a very large file with very long lines?

It turns out I was accidentally using grep wrong yesterday. I just checked my bash history and saw what I was executing: grep search-string-here -f large-file-with-long-lines.txt And that was what ...
0 votes
1 answer
52 views

Search for specific part of a line

I want to have this script which will store users in the format:<$AccountName> <$DOB> <$Username><$Password> <$Email> on a file called Register.txt. I want to have it ...
  • 1
0 votes
2 answers
64 views

Search with less

In the output of wget --help I would like to quickly go to the place where the --header option is explained. I try searching with less. man less explains: /pattern Search forward in ...
  • 913
-1 votes
2 answers
1k views

Checking files for a string using a loop

I'm trying to loop through files in a directory that start with the string stated in the for statement. Within the loop, I want to search for the pattern string foo within the file. If the string is ...
0 votes
4 answers
3k views

How to loop through all files in the current and sub directories to find a string? [closed]

Hi I am trying to loop through a directory and all its subdirectories to find the string 'foo' in all the files, for example. I then want to display the file names (including full path) of all files ...

1
2 3 4 5
12