My single most used grep command

Often all I need is to find matches in a group of files of a single pattern. But I always forget the grep command for it. This does not come up very often – that’s probably why. In any case, thank you intarwebs for allowing me to have this cheat sheet that is my blog.

The line is:

grep -Riln "pattern-to-search" "path-to-search-directory"

-R is dereference-recursive option, where the search recurses into subdirectories but follows symlinks (use -r if no follow symlinks).

-i ignores case or searches case-insensitive

-l prints only files with pattern search matches

-n prints line numbers with output lines

Advertisements

Node JS: install nvm on Ubuntu

One will need to ensure that compiler and development SSL library is available before specifying nvm installation in Ubuntu 14.04/16.04 LTS.

sudo apt install build-essential libssl-dev

Then get the package and install

curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | sudo bash

After that, exit out of user account and login again. See if you can install a specific version of node js, let’s say 6.10.0. You can see what is available by issuing:

nvm ls-remote

You should see all available version, including 6.10.0. To install:

nvm install 6.10.0
nvm use 6.10.0

Get some help by issuing

nvm help

If you want multiple versions, install the other versions as necessary using the steps above. Would be good to select a default. If we want to default to 6.10.0 do the following:

nvm alias default 6.10.0

 

 

Vim: Setting up with .vimrc

I use Vim 6+. I like to have basic things set up on vim to get going. Often though, I do not remember the setting commands. Simple things like syntax highlighting, auto-numbering of file lines, auto indentation, tab expansion and tab width in character spaces.

After installing vim on your POSIX compliant machine, go to your home directory and edit or create the new .vimrc file:

user@machine:~$ cd && vim .vimrc

Below is what I enter to get started:

:set syntax=on
:set number
:set autoindent
:set expandtab
:set shiftwidth=2
:set softtabstop=2