Posts Tagged With: grep

Find files of a specific mime-type

Tagged with: , , , , , , ,

Use this command to find files of a given mime-type. In this example, we are looking for video files…


find -type f -print0 | xargs -0 file -i | grep -i video

And, by the way, this command, and the last two commands were sponsored by Mahesh. Happy now?

1 Comment »

Optimized Grep Searching

Tagged with: , , , , , , ,

Grep that searches recursively, ignores binary files, and doesn’t look inside Subversion hidden folders.


grep -Ir --exclude="*\.svn*" "pattern" *
No Comments »

Fish Shell Command History Meme

Tagged with: , , , , , , , ,

Use this command if you want to know your command usage stats in the fish shell.


grep -v "^\#" ".config/fish/fish_history"|awk '{print $1}'|sort|uniq -c|sort -rn|head -n10
No Comments »

Grep using Sed

Tagged with: , , , ,

View only lines that contain the word “string”


sed -n '/string/p'
No Comments »

Seach for a String in a Folder using grep

Tagged with: , , , , ,

Search string “test_text” at directory ‘/var/log’ and below


grep test_text -R /var/log/*
No Comments »

Graphical representation of sub-directories

Tagged with: , , , , , ,

This command shows a graphical representation of the current sub-directories.


ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'mand

Original Article

No Comments »

Recursive Grep

Tagged with: , , , ,

Recursively check a folder to find the given text using grep


grep -R "text" *
No Comments »

Pid Command

Tagged with: , , , , , , ,

Create a command that will return the pid of the given command string..


#!/bin/sh
ps aux|grep $1|head -n1|awk '{print $2}'
No Comments »

Sensex Figure using a Linux Command

Tagged with: , , , , , , ,

This one command will fetch and display the latest sensex figure in Linux. This command basically downloads a page, locates a specific line, and then extract just the necessary portion from it. I am sure you could find other uses for this method.


curl -s "http://money.rediff.com/money/jsp/markets_home.jsp" |grep ''|head -n1|perl -pe 's/^.+\">([\d\,\.]+)<\/TD>.+$/\1/i;'
No Comments »

Search Text in a Folder using grep

Tagged with: , , ,

Search for a specific text in a folder using grep


grep "fetchFeedPacksCustomize()" *.js

[tags]grep,search,text,folder[/tags]

No Comments »