Tag Info

Hot answers tagged

64

locate(1) has only one big advantage over find(1): speed. find(1), though, has many advantages over locate(1): find(1) is primordial, going back to the very first version of AT&T Unix. You will even find it in cut-down embedded Linuxes via Busybox. It is all but universal. locate(1) is much younger and nonstandard. The earliest ancestor of ...


35

Here is one way to get the exact output you're looking for: $ grep -nFx "$(sort sentences.txt | uniq -d)" sentences.txt 1:This is sentence X 4:This is sentence X Explanation: The inner $(sort sentences.txt | uniq -d) lists each line that occurs more than once. The outer grep -nFx looks again in sentences.txt for exact -x matches to any of these lines ...


29

You can access this via the forward-search-history function which is bind per default to ctrl+s. Unfortunately ctrl+s is used to signal xoff per default which means you can't use it to change the direction of the search. There are two solutions for solving the problem, one disabling sending the xoff/xon signaling and the other change the keybinding for ...


28

If you have poppler-utils installed (default on Ubuntu Desktop), you could "convert" it on the fly and pipe it to grep: pdftotext my.pdf - | grep 'pattern' This won't create a .txt file.


26

Install the package pdfgrep, then use the command: find /path -iname '*.pdf' -exec pdfgrep pattern {} +


18

Try this trick : man foobar | less +/searched_string or man foobar | more +/searched_string this should do the joke.


17

The first place to look is your distribution's package list. That's where you'll find the easiest-to-install programs. Some package management tools provide advanced ways of searching it. On Debian and Debian-based distributions (e.g. Ubuntu), you can search package descriptions with apt-cache search or aptitude search (on the command line), or through the ...


17

You may have a look at rlocate, a reimplementation of locate that is always up-to-date. Another interesting project is recoll which also supports real time indexing and allows you (like beagle) additionally do full-text searches. Finally I should mention doodle which also supports real time indexing. For doodle there are some nice frontends like catfish. ...


15

For quickly getting help on a Bash builtin, use help: help read is what you want. For man-page-like formatting, use help -m read or, even better, help -m read | less If you still insist on looking for it in the man page, I find what quickly gets me to a command's explanation is /^\s*read [[] This works because when a command is first explained, ...


14

You have a lot of options! pdftotext from poppler has already been mentioned. There's a Haskell program called pdf2line which works well. calibre's ebook-convert commandline program (or calibre itself) is another option; it can convert PDF to plain text, or other ebook-format (RTF, ePub), in my opinion it generates better results than pdftotext, although ...


14

$ find . -type f -print0 | xargs -0 grep foo $ grep -r foo . # GNU grep only and in zsh with setopt extendedglob, $ grep foo **/*(.)


13

I find it surprising how fast does locate work or the autocompletion (that I know) work in linux. ... Is there any indexing being done in the background or how is this achieved? This is actually two completely distinct questions. locate uses an index (slocate stores it in /var/lib/slocate/), that is updated by a nightly cron job. This nightly job ...


13

I think what most closely fits what you're looking for is apropos (a.k.a. man -k), which will search the one-line descriptions preceding every manpage. If you want to search through whole manpages, at least man-db supports man -K, which does exactly this (man-db is the man implementation used on at least Debian derivatives by default). IIRC, man -K is ...


12

locate uses a prebuilt database, which should be regularly updated, while find iterates over a filesystem to locate files. Thus, locate is much faster than find, but can be inaccurate if the database -can be seen as a cache- is not updated (see updatedb command). Also, find can offer more granularity, as you can filter files by every attribute of it, while ...


12

Add ~i (short for ?installed) to match the installed packages whose name contains bash: aptitude search '~i bash' To match whose description contains bash. aptitude search '~i ~d bash' To limit to the ones that are not installed: aptitude search '!~i bash'


12

I generally use a tool called pcregrep which can be installed in most of the linux flavour using yum or apt. For eg. Suppose if you have a file named testfile with content abc blah blah blah def blah blah blah You can run the following command: $ pcregrep -M 'abc.*(\n|.)*def' testfile to do pattern matching across multiple lines. Moreover, you can ...


12

You can concatenate several paths for grep to look for: grep -r "some string" /code/internal/dev/*.cs /code/public/dev/*.cs /code/tools/*.cs


11

From the Surfraw website: Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, babelfish, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they ...


11

search and limit can also actually search inside messages, depending on the search patterns you give. From the Patterns subsection of the Mutt reference: ~b EXPR messages which contain EXPR in the message body ~B EXPR messages which contain EXPR in the whole message That is, ~b only searches in the body, whereas ~B also searches in the ...


11

You may find q: useful. It opens the command-line window. The command-line window looks like this: I tried to make an animation of its usage: Also see c_CTRL-F, which opens the command-line window from command mode. You can also re-run the last command from normal mode by typing @:.


11

If you want to grep recursively in all .eml.gz files, you can use: find -name \*.eml.gz -print0 | xargs -0 zgrep "STRING" You have to escape the first '*' so that the shell does not interpret it. "-print0" tells find to print a null character after each file it finds; "xargs -0" reads from standard input and runs the command after it for each file; ...


10

You can do either of grep pattern_search . # does a normal grep on the current directory grep pattern_search * # use a normal grep on all the globbed files from the current directory grep -R pattern_search . # use a recursive search on the current directory grep -H pattern_search * # prints filename when the files are more than one. ‘-H’ Other ...


10

Assuming I understood your question, you are possibly overcomplicating it. This should do find your_directory -type f -name '[az]*[az]' This omits files whose name is a single letter a or z. If you also want to include them, you need to specify another pattern: the name must match either [az]*[az] or [az]. find your_directory -type f \( -name '[az]*[az]' ...


10

You seem to be looking for find: find . -type f -name "*foo*" would look for file names containing foo in the name in the current directory and subdirectories. find . -maxdepth 1 -type f -name "*foo*" would look for file names containing foo only in the current directory.


9

After more searching, it looks like the easiest way to do this is with \_s. So for example: /hello\_sworld


9

Have you looked at Lucene or Sphinx? While you will need to initially parse the documents you want to index, once that's done, either one can search from the cli. For Lucene, there is some info on doing this available. Sphinx, is a bit more vague, but there is also some documentation available. You can pass structured XML data of your choice to sphinx ...


9

Grep is doing all right. That file does not contain any lines with ":youtube.com". If you want to match all that lines with : you could use grep ":.*youtube\.com" UPD: As you've update your question, I need try to answering second part. From the list above (youtube.com, youtube.com.br), I only should get youtube.com, but I don't get anything. ...


9

Try the pgrep command, which will output the PID of the command you're interested in. pgrep selenium To actually kill the process, use the companion pkill command. pkill selenium


9

GNU grep has the following options: grep --only-matching --ignore-case --fixed-strings --file /usr/share/dict/british-english-insane /path/to/file.txt This outputs strings found one-per-line. Here /usr/share/dict/british-english-insane is a wordlist provided by the Debian package wbritish-insane.



Only top voted, non community-wiki answers of a minimum length are eligible