New answers tagged

6

grep -f <(sed 's/.*/\^&\\>/' town-list.txt) ma-towns.txt Explanation: grep -f file reads file for a list of patterns to match against. We are searching in the ma-towns.txt list, using patterns from town-list.txt. Each separate line is treated as a new pattern, i.e. a new search term. However, that's not quite enough, so I've included a sed to ...


5

This will read the lines of file2 and parse file1 with grep using the lines : while read line; do grep "${line}" file1 done < file2


2

The pcregrep utility supports matching for multi-line patterns, so this is easy. First, you need a list of files to search within; in a git repository, my own git find utility can be useful for this, but regular find(1) and other tools will also do. Pass the list of files to pcregrep, dump its output into a temporary file, then hand-review the file list (e....


3

With zsh: setopt extendedglob # best in ~/.zshrc ls -ld -- (#ia1)hello # case-insensitive, allow one error ls -ld -- (#ia2)hello # case-insensitive, allow up to two errors. Recursively, search hidden files (and in hidden dirs) as well ((D)): ls -ld -- /**/(#ia2)hello(D) (note that it doesn't do any sorting by similarity, only ls's sorting by name of ...


1

It is certainly possible, although not popular. I've never really used the tool, but I know what too look for; you might want to try fzf. Generally, what you want is so called "fuzzy search", name derived from fuzzy logic. You know more or less what you want. The more or less part makes it fuzzy. I would give fzf a try if I were you, but consider other ...


0

I know it's over a year ago, but I just wanted to add to the answer by cipricus. You need to go to the tab "Appearance Conditions" (next to the "Basic" tab) and put a tick in the boxes for the file types you want. Then catfish works. And yes, it's fast! Regards


2

Here's one possible way sed '/)\. $/ { n /^PORT/ i\ 0 closed ports }' Testing $ sed '/)\. $/ { n /^PORT/ i\ 0 closed ports }' < input ... Nmap scan report for w.x.y.z (x.x.x.x) Host is up (0.00090s latency). 0 closed ports PORT STATE SERVICE 21/tcp open ftp ... Nmap scan report for w.x.y.z (x.x.x....


0

You can use N in sed to pull next line of input in the pattern space, and then work on two lines at once. As an example, conditionally pull the next line in when seeing a foo, and then do a replacement on both lines. (Note that consecutive lines with foo will break this.) echo -e "asf\nfoo\nbar" | sed -e '/foo/N;s/o\nb/od\nc/' Also, GNU sed has the -z ...


2

The apropos command (or man -k) will return all manuals that contains the specified search term in the NAME section (the first section in any manual on Unix). This section is stored in the "whatis"-database. To find a command that handles "space" do $ apropos space On OS X, that will find df ("display free disk space") and other related things (but ...


2

I would do it in two find calls: One to find all zip files and then process them Another to deal with the regular files This is a little cumbersome, the complicated part is the awk call. It processes the output of unzip -l which is not very script friendly. It searches for lines starting with numbers (to get rid of the headers), gets rid of empty lines,...


1

For those who haven't upgraded to Linux Mint Mate 18, there is a fix to have the menu select the top entry in the search form. This worked for me on Mint Mate 17.3. First, find the applications.py file that corresponds to your Mint menu: $ locate applications.py /usr/lib/linuxmint/mintMenu/plugins/applications.py /usr/lib/python3/dist-packages/ufw/...


2

You scan the file once for each pattern. It would be a lot faster to go through the file only once, especially since the file doesn't fit in cache. Your sample code actually only saves the matches from the last pattern in file1. I assume that this is an oversimplification. If you need all the matches in a single file, then it's as if the patterns were ...


0

I bet you are using php-fpm. This is a known bug in Apache 2.4.6. Timeout and ProxyTimeout are ignored and the value 30s is hardcoded. It is fixed in Apache 2.4.8. Here are two links you should read bugzilla error post Solution if you intend to recompile Apache on your own


3

You can position the cursor on the first match using the -s (script) option. According to the vim manual: -s {scriptin} The script file {scriptin} is read. The characters in the file are interpreted as if you had typed them. The same can be done with the command ":source! {scriptin}". If the end of the file is reached before the editor exits, ...


0

I considered using the +/ command option which is documented in the man page as +/{pat} – For the first file the cursor will be positioned on the first occurrence of {pat}. However, the description in the man page is misleading, i.e., the cursor is actually placed on the first character of the first line that contains the search pattern, similar to how ...



Top 50 recent answers are included