My Science Is Better

16Jan/111

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.

Tagged as: , , , 1 Comment
8Jan/101

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!

   

Tag Cloud

Categories

Archives

Akismet

Blogroll

Ads