Categories
linux ubuntu

Find string in files and show line number with grep

Handy snippet to find some string inside the files in a directory:

grep -r --line-number "string_you_search" path/where/to/look

Note the -r tells grep also to look into all subfolders recursively.

Categories
linux ubuntu

Enable ls color support

By default i like to use the Green on Black color scheme with my terminals. When i enable the theme though, ls loses somehow the ability to show files in colors. The trick to enable the feature is simple. One just has to run ls like this:

ls --color=auto

Unfortunately this won’t stick, and it’a a bit of a drag to always add the –color=auto part. To solve this, one has to create an alias to ls to point to ls –color=auto. You can do this by adding the following to ~/.bashrc

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
fi

Tada!