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.

learn more… | top users | synonyms

4
votes
2answers
38 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 ...
1
vote
1answer
31 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
37 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: ...
1
vote
0answers
24 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
2answers
44 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
46 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
39 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 ...
1
vote
1answer
35 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 '/$...
2
votes
2answers
49 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 ...
1
vote
1answer
34 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
63 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 ...
2
votes
3answers
148 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
44 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
40 views

What does the “pipe” command do in mailx?

When using the mailx command line utility, there is a command called pipe listed in the man page (although not visible when using the help command). What does this command do? I want to be able to ...
0
votes
0answers
26 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
92 views

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

Relatively new to unix and still learning -- 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
36 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
33 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 ...
4
votes
4answers
503 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
38 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 ...
0
votes
0answers
13 views

searching through command line history [duplicate]

I use reverse search when looking for a particular command on the command line by pressing CTRL + R. That returns the first command it finds in reverse order. To go back to the next further command I ...
1
vote
2answers
49 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
35 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 ...
0
votes
0answers
56 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 ...
6
votes
1answer
328 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
29 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 ...
0
votes
2answers
239 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
26 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
192 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
20 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
216 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 ...
0
votes
0answers
27 views

Linux replacement for Übersicht

Is there anything like Übersicht (for OSX)? It don't have to be 1-to-1 port, but in general I'm searching for an option to script widgets on desktop with html/css/js/shell-support.
3
votes
2answers
125 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
67 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
143 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
0answers
45 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
25 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 Kate 15.08.2, is it possible to search for [[i]] in each file and ...
1
vote
2answers
91 views

Mate menu (Linux Mint 17) searches files when pressing enter - can this be changed?

Example: I press Supper button: menu opens. I write "fir": it shows Firefox, just like any launcher. I press Enter, it starts searching the whole system for files named "fir". I can avoid this by ...
1
vote
2answers
37 views

How do I find a substring in a command line?

I have a few files that contains a similar entry like as follows: {"result":[]} {"result":[{"alternative":[{"transcript":"I win","confidence":0.87958056},{"transcript":"when"},{"transcript":"Schwinn"}...
3
votes
1answer
103 views

Regular Expression to match (not x) and y (!x & y)

I received a desktop day-to-day calendar with puzzles. One such puzzle was deciphering a quote where the letters were substituted with symbols. I used some RegExs to find longer words, then used the ...
0
votes
0answers
25 views

Regular freeze/lag in search

I have a problem with the search (Super) in Debian Jessie with Gnome 3.14.0. When I open the search screen (with the Super button) and start typing, the interface freezes after two characters, for ...
3
votes
1answer
42 views

Why do less search result lines disappear/reappear?

When skimming through a file with less, I'm able to see all lines just fine. When I do a search and then go for the next result with n, sometimes a highlighted result is shown on the top line, and ...
0
votes
2answers
463 views

Search for a specific word in each line and print rest of the line

I have text file with server URL lines like: request get https://abc.net/search?q=hello/world/hello/word/search=5&size=10 request get https://abc.net/search?q=hello/world/hello/world/hello/word=5 ...
7
votes
2answers
431 views

Binary search in a sorted text file

I have a big sorted file with billions of lines of variable lengths. Given a new line I would like to know which byte number it would get if it had been included in the sorted file. Example a\n c\n ...
0
votes
1answer
313 views

New search in Mate desktop menu doesn't replace the previous one

In the Mate desktop it is easy to launch applications with the menu search (menu pops up with the default Super_L key). But it remembers the initial search in such a way that when I try to launch a ...
3
votes
1answer
40 views

grep search for any number in a range

So I have a file with a number of records that look like the following: Peugeot:206:2000:Red:1 And I'm trying to grep search for any that contain a year 1995-1999. I have tried grep '[1995-1999]' ...
2
votes
2answers
87 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 ...
-1
votes
1answer
67 views

How to write a Shell Script to find Inputs/Output of a Function in a given file

I need to write a shell script which tells us all function names in a given file and their inputs/outputs For Example consider the below file which has 2 functions. Each function has their input and ...
0
votes
1answer
61 views

Unwanted and or Abusive Web Requests

We have been contacted by our server host provider about Unwanted and or Abusive Web http Requests going out from our server. The information they gave us are. Block Type: New Ban Time: 2015-10-01 ...
4
votes
2answers
71 views

How to use the results of “file” (Name of Creating Application: Microsoft Word) to search for a specific string?

I am trying use the results of "file" which returns info about the file/s I specify. E.g. file *.doc 'all .doc extensions This then returns information about the file including "Name of Creating ...