Posts Tagged With: grep

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 »

Better Way to find Process ID of an Application in Linux

Tagged with: , , , , , , ,

A better way to get the process id of an application. I recommend giving an alias for this command…


ps aux|grep firefox|awk '{print $2 "\t\t" $12}'|head -n1

Replace firefox with the name of the application you are searching for.

[tags]linux,command,cli,awk,ps,process,id,grep[/tags]

No Comments »

Searching text in a directory using find and grep

Tagged with: , , , , , , ,

Use find and grep to search for a specific text in a directory. In this example, we search for files which uses the PHP short tag - <?


find -name '*.php' -exec grep '<?[^p\=]' {} \;
No Comments »