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
1
vote
1answer
273 views

How to remove/alter search results from Linux Mint start menu?

Linux Mint 18.0 Cinnamon Edition has a start menu, which can quickly be launched with the windows key. Typing thereafter brings up search results, which have a functional or descriptive relation to ...
4
votes
3answers
3k views

sed string replacement for exact match containing /

I am trying to use sed to search for the occurrence of an exact string that contains / in it. Below is the approach I am trying, but without luck. input_string="/path /path1 /path2" search_string="/...
1
vote
3answers
280 views

Grep something specific of the results of last execution?

I've installed some utilities from the CLI and got quite a long verbose output describe what was installed directly, what needed some dependencies, what is no longer needed to be installed, etc. Is ...
1
vote
1answer
27 views

Is there a way to find patches which need testing from packages you have?

$ dpkg -l Gives you a list of all packages installed on your system. Now some bugs on the Debian BTS are tagged patch . Now is there a way to list all packages which are installed on your system for ...
-1
votes
2answers
103 views

Multiple years grep [closed]

How can I grep exact years in my file which contains world champions from years 1950-2000 but I want only years 1950/60/70/80/90/00? Thank you so much
0
votes
3answers
2k views

Search multiple directories and output file names

I have a list of 7 directories. Every day they get a file. I would run one command that would check all the directories at once which provides the output of the file names. Normally I run ls /...
4
votes
3answers
4k views

List files in all subdirectories by creation date

I have forgotten the name of a file which is in a directory or one of its subdirectories. I remember the file's extension (.nb) and know approximately when it was created. How can I list all file with ...
1
vote
1answer
791 views

Finding a missing sequential number in a data file

How can I search a large file with 'sequential numbers' (that reset after 16) in a particular column to find a missing line? I have a data file: col1 col2 col3 col4 col5 1 col1 col2 col3 col4 col5 2 ...
-1
votes
1answer
83 views

finding specific directories

I need to find all directories that begin with dirD in the directory /dirA/dirB/dirC. Basically, dirD*. So far I tried: find . -type d -name "dirD*" and ls -lrt | grep "^d" | grep "dirD*" Now I'm ...
9
votes
4answers
2k views

How to find files that don't have empty line at the end?

I have files in subdirectories of the current directory that may or may not have new lines at the end; how can I find files that don't have a newline at the end? I've tried this: find . -name '*....
0
votes
2answers
1k views

Grep a string from the same file in multiple .tar.gz files [duplicate]

I have multiple *.tar.gz files. They all contain files with file name a, b, and c. Is there a way to grep string 'foo' only from file b under these multiple *.tar.gz files without extracting the files....
2
votes
0answers
448 views

reverse-i-search not showing all results compared to grep

I have always used reverse-i-search to grab my old commands, however for some reason its not returning all the results, at least the results I am expecting. desired command cat ~/.bash_history | ...
6
votes
4answers
4k views

Trying to use `pwd` inside an alias giving unexpected results [duplicate]

If I want to search a file in the system I use the following command: sudo find `pwd` -name filename.ext I want to make an alias for an easier word like search, so I used the command: alias search "...
2
votes
2answers
219 views

How do I force ag (the silver searcher) to list empty files

How do I get ag to list all files, including empty ones? +ravi@boxy:~$ mkdir new && cd new +ravi@boxy:~/new$ echo stuff > non-empty && touch empty +ravi@boxy:~/new$ ag -ul non-...
0
votes
1answer
256 views

Why is ag printing blank lines from this file?

I want to use ag to print the classes and their methods in a python file. I thought that this would be easy using: ag --context=0 --nocolor -os '^\s*(def|class)\s+[_A-Za-z]*' prog.py but for reasons ...
3
votes
0answers
2k views

Kate can't show some newline characters using escape sequences

Kate and KWrite both don't show all \n characters. Problems appear to be next to where there are empty lines. The problem isn't just in the highlighting itself. Wrong number of matches are found. ...
4
votes
2answers
12k views

How to extract lines from a text file that contains strings from a list in another file? [duplicate]

I have a file containing population information for a bunch of towns. I have another file that is a list of the names of a subset of those towns. I want to select the population information from the ...
3
votes
2answers
743 views

How do I find files with multiple empty lines?

For replacing multiple empty lines with just one I need to find which files to apply this in the first place, in a big repository. How do I do that?
1
vote
2answers
488 views

list files with similar names sorted by similarity [closed]

Is it possible to search files and list them descending by similarity ? e.g.: Following files are in /: heo HELLO helo hello When I search for 'hello' I would like to have a List like: hello ...
3
votes
0answers
126 views

Using ack to effectively search and RStudio project directory

I'm interested in running ack search on a RStudio project directory that mostly contains *.R script files but also some project files and often *.git files. Directory The project folder structure ...
1
vote
3answers
826 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 ...
2
votes
1answer
112 views

What command(s) can I use in a terminal to find a program that does a particular thing? [duplicate]

I often find myself alt-tabbing to google "How to do X in Linux". Is there a way to search (say, man pages) in Linux to find tools that might be of use in a particular situation? For example, ...
2
votes
1answer
868 views

Search for files inside multiple subdirectories and zip directories [duplicate]

I need to extract more than 2k files from 1000 folders..the problem is, each folder has a zipped folder inside and inside this folder, there is another folder called "fileholder" which contains some ...
2
votes
1answer
374 views

read patterns from file1 and search them iteratively in file2

I'd like to read patterns from file1 and search them iteratively in file2, printing the matched line plus 3 rows, and print them to file3. Now I am doing: cat file1 | while read line; do awk '/$...
3
votes
2answers
727 views

How to open a file in VIM and move cursor to the search result

Consider the file tmp.txt whose contents are: x abcd I want to open it in VIM and move cursor to the c character. So I run VIM with the arguments: $ vim -c "/c" tmp.txt But it sets the cursor on a....
1
vote
1answer
100 views

how to search file for begin of string and save a variable

i am trying to find a way of searching a file for string, it needs to work by searching then file and if any line in the file begin with what i am searching for, then take that whole line and save it ...
0
votes
3answers
190 views

Vim Search and Replace - Regex

I want to perform a search and replace. A newline before any non-digit should be replaced with tab. I tried %s/\n\D/\t/g but it replaced the first character of the word following the newline, which ...
1
vote
3answers
668 views

How to search a text file for a specific integer

Is there a simple way to search a text file (source code) for all instances of a specific integer. This should not trigger on larger numbers that happen to include the integer as a sub-string, but it ...
2
votes
1answer
1k views

How can i replace multi line string using sed? [closed]

I have tried the following command:- [root@10 bin]# cat temp asdjahskjdhajksdhjkashjahfksjdhfkjsddhflkdsjhfklsdajhfklajshdkjalsdlkjasdhkljas hskdajkdhkjas cast $recv $UE_CAPABILITY_ENQUIRY ...
0
votes
0answers
65 views

To forward-search in Raspbian's Bash?

Keybinding CTRL-S is enabled by default in Debian/Ubuntu/OS X bun not in Raspbian. I can enable the reverse-search by in $HOME/.bashrc, which disables XON/XOFF, but it does not help with the forward-...
1
vote
2answers
967 views

search for files with specific text and copy these files to another directory

How do I search for files in a directory that contain a specific text and copy them to another directory ? I am using .ksh shell.
1
vote
1answer
44 views

changing a specific 'column' inside a txt file

I have a file with thousands of entries like this: 6/05/2016,32,34,40,45,48,,01,10 10/05/2016,02,26,27,40,49,,05,10 13/05/2016,07,15,28,31,42,,10,11 17/05/2016,15,27,32,36,39,,03,10 I want to ...
0
votes
1answer
427 views

how to print the count of matched /unmatched patterns and print multiple patterns separated by line

how to print the count of matched /unmatched patterns and print multiple patterns separated by line. Input example (test.log): This 23 line has eight 8888 This 11 line has three 3333 need 12 to ...
5
votes
4answers
7k 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&...
1
vote
1answer
283 views

How to set default personality for a kernel?

I'm trying to replace a 32-bit kernel with a 64-bit one on a 32-bit system, so that I had the complete support for 64 bits for the apps which need it (provided they have the necessary libraries or are ...
2
votes
2answers
2k views

How to extract a function from file? [closed]

I am looking for a command to extract a C function from my code. It would be something like: $ grep -func "MyFunction" foo.c int MyFunction(int i) { return i+1; } I know we can extract it with ...
0
votes
2answers
50 views

searching a file [closed]

I want to find in the system a file, and I know part name of it. How could I do that? I tried unsuccessfully the command: find / "*partname*" The problem is probably very easy however I cannot find ...
4
votes
1answer
4k views

How to search a log file in Linux and escape special characters like square brackets (i.e. [ and ])

How to search a log file in Linux and escape special characters like square brackets (i.e. [ and ]) Can someone point me in the right direction on this? I less the log file as per below: less ...
8
votes
1answer
4k views

grep --exclude does not exclude my file

I am searching a dir for a particular string (to see all instances of where the string is present and in which files). However, I want to exclude one particular file from being searched. Here's what ...
1
vote
1answer
69 views

bash - isolating uppercase words

So, I have a directory containing around 50 directories having for name 3 letter uppercase words: AXC BCC EFC amongst other directories. I have already done a find to seek these 3 letter directories ...
3
votes
2answers
48k views

How to find and edit “Apache timeout”?

I'm trying to view the default value of Apache timeout of my server, but I found nothing about that in /etc/httpd/conf/httpd.conf . So where is " timeout " supposed to be and how do I change its value ...
0
votes
1answer
225 views

How do I extract specific URLs from an HTML file [duplicate]

I have an HTML file, without any formatting. I want to extract URLs of the form https://sitename.com/*/ending and only those URLs. What is the best way to go about doing this? This question is NOT a ...
4
votes
3answers
650 views

How to search efficiently for a list of strings in a big code directory

I have a list of strings, for every of those strings, I want to check if it occurs in a big source code directory. I came to a GNU grep solution that gives me what I want: for key in $(cat /tmp/...
1
vote
0answers
345 views

Search for occurrences of text in a long line in less

I am using less to view a file with many long lines. less automatically wraps these lines, but when I use / and n to search for something, it only shows the first occurrence of the text on a line. ...
2
votes
3answers
1k views

Find and rename files (including directories) whose filenames contain space [duplicate]

I have quite a number of files and directories with spaces in their filenames in my ext4 filesystems. How should I safely find and rename them? I have bash and am running Ubuntu. Is it possible ...
3
votes
2answers
223 views

How is it that the same find command can give two different results?

This has happened to me twice (EDIT: many times and I can replicate it) now. I'm working on a Raspberry Pi, looking for a file I already know exists and so I type this command: sudo find / -iname '...
1
vote
1answer
163 views

Search a string in files in the current directory, omit duplicates

Assuming I want to write a line which prints out lines which match a specific string without repeating duplicate lines .. I want to search for this string in the files of the current directory: grep ...
1
vote
3answers
532 views

Finding and removing words beginning / ending with numbers

I have a large file (>10000 lines) that contains one word per line, with a newline character after each word. The words contain no spaces. I'd like to list (or even better, output to a new file) any ...
0
votes
1answer
65 views

Unix scripting : Writing to another file with “:” is failing

I have below record (and many other such records) in one file 9460 xyz abc (lmn):1027739543798. Taxpayer's identification number (INN): 123. For all IIB. 2016/02/03 I need to search ...
0
votes
2answers
50 views

search string in files and replace it incrementally

I have a directory with 152 files named plot_1 to plot_152. In each of those there's some R code with some index [[i]]. Using Kateversion 15.08.2, is it possible to search for [[i]] in each file and ...