
Terminal - Commands using egrep - 168 results
iwlist ath0 scanning |egrep '(ESSID|Signal|Address)'| \sed -e 's/Cell - Address:*//g' -e 's/ESSID://g' \-e 's/Noise level=-//g' -e 's/dBm//g' \-e 's/Quality=*//g' -e 's/Signal level=-//g' \-e 's/"//g'
This is sample output - yours may be different.
svn ls -R | egrep -v -e "\/$" | tr '\n' '\0' | xargs -0 svn blame | awk '{print $2}' | sort | uniq -c | sort -nr
This is sample output - yours may be different.
make usable on OSX with filenames containing spaces. note: will still break if filenames contain newlines... possible, but who does that?!
This is sample output - yours may be different.
DATE=`date +"%H:%M" --date '-1 min'`; egrep "\ $DATE\:..\ " /var/log/dhcpd.log |awk '/DHCPREQUEST/ {split($3,t,":"); printf("%02d:%02d\n",t[1],t[2]);}' |uniq -c;
This is sample output - yours may be different.
alias gfind='find . -print0 | xargs -0 egrep -I '
This is sample output - yours may be different.
du --max-depth=1 -h * |sort -h -k 1 |egrep '(M|G)\s'
This is sample output - yours may be different.
Enhanced version: fixes sorting by human readable numbers, and filters out non MB or GB entries that have a G or an M in their name.
tcpdump -i eth0 port http or port smtp or port imap or port pop3 -l -A | egrep -i 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|userna me:|password:|login:|pass |user '
This is sample output - yours may be different.
du --max-depth=1 -h * |sort -n -k 1 |egrep 'M|G'
This is sample output - yours may be different.
man ls | egrep "^([A-Z]| [A-Z])"
This is sample output - yours may be different.
LS(1)
NAME
SYNOPSIS
DESCRIPTION
Exit status:
AUTHOR
REPORTING BUGS
COPYRIGHT
SEE ALSO
GNU coreutils 7.4
Uses the formatting of a man page to show an outline of its headers and sub-headers.
ls -l /dev/disk/by-id | egrep ata-.*`hdparm -i /dev/sda | grep SerialNo | sed 's/.*SerialNo=//' | tr -d "\n"`.*sda$ | sed -e 's/.*ata-/ata-/' -e 's|[ ].*||' | tr -d "\n"
This is sample output - yours may be different.
This was tested on Ubuntu 12.04 (Precise) LTS Server. It returns the name of the symlink within /dev/disk/by-id for the physical drive you specify. Change /dev/sda to the one you want, and replace ata- with scsi- or the appropriate type for your drive.
I used this to pre-configure grub-pc during a non-interactive install because I had to tell it which disk to install grub on, and physical disks don't have a UUID such as that blkid provides.
export DISPLAY=$(tr '\000' '\n' < /proc/`pidof Xorg`/cmdline | egrep '^:[0-9]+')
This is sample output - yours may be different.
Not always does Xorg run on :0. For times like those, this script allows you to find out which it is.
egrep -v '(\t)?#.*|^$' /etc/apache2/sites-available/default
This is sample output - yours may be different.
find . -type f |egrep '^./.*\.' |sed -e "s/\(^.*\.\)\(.*$\)/\2/" |sort |uniq
This is sample output - yours may be different.
bak
bat
cfg
conf
csv
doc
exe
exe_back
pyc
sql
txt
xls
find files recursively from the current directory, and list the extensions of files uniquely
curl -s mi-ip.net | grep '"ip"' | cut -f2 -d ">" | egrep -o '[0-9.]+'
This is sample output - yours may be different.
looks at html for "ip" (it's a CSS class), then a little of cut and egrep to get IPv4 address.
I use this oneliner into conky.
source <(egrep '^#define EX_.*' /usr/include/sysexits.h | sed -e 's/#define/declare -r/g' | sed 's/\//#/g' | sed -e 's/\s\{1,\}/ /g' | sed -e 's/ \([0-9]\)/\=\1/'g )
This is sample output - yours may be different.
declare -r EX__BASE=64 #* base value for error messages *#
declare -r EX_USAGE=64 #* command line usage error *#
declare -r EX_DATAERR=65 #* data format error *#
declare -r EX_NOINPUT=66 #* cannot open input *#
declare -r EX_NOUSER=67 #* addressee unknown *#
declare -r EX_NOHOST=68 #* host name unknown *#
declare -r EX_UNAVAILABLE=69 #* service unavailable *#
declare -r EX_SOFTWARE=70 #* internal software error *#
declare -r EX_OSERR=71 #* system error (e.g., can't fork) *#
declare -r EX_OSFILE=72 #* critical OS file missing *#
declare -r EX_CANTCREAT=73 #* can't create (user) output file *#
declare -r EX_IOERR=74 #* input#output error *#
declare -r EX_TEMPFAIL=75 #* temp failure; user is invited to retry *#
declare -r EX_PROTOCOL=76 #* remote error in protocol *#
declare -r EX_NOPERM=77 #* permission denied *#
declare -r EX_CONFIG=78 #* configuration error *#
declare -r EX__MAX=78 #* maximum listed value *#
Use meaningful exit codes
change "source" to "cat" to view output instead of assigning
lsmod | tail -n +2 | cut -d' ' -f1 | xargs modinfo | egrep '^file|^desc|^dep' | sed -e'/^dep/s/$/\n/g'
This is sample output - yours may be different.
curl url | egrep -o '(http|https)://[a-z0-9]*\.[a-z0-9]*\.[a-z0-9]*'|sort |uniq
This is sample output - yours may be different.
curl http://photobucket.com/ | egrep -o '(http|https)://[a-z0-9]*\.[a-z0-9]*\.[a-z0-9]*'|sort |uniq
http://ad.crwdcntrl.net
http://beta.photobucket.com
http://blog.photobucket.com
http://b.photobucket.com
http://b.scorecardresearch.com
http://clk.atdmt.com
http://i0006.photobucket.com
http://pic.pbsrc.com
http://pic.photobucket.com
http://rc.rlcdn.com
http://register.photobucket.com
http://rome.specificclick.net
https://login.photobucket.com
http://static.pbsrc.com
http://support.photobucket.com
http://tags.crwdcntrl.net
http://view.atdmt.com
http://www.facebook.com
http://www.photobucket.com
http://www.smartrecruiters.com
http://www.w3.org
Get link to external sites of a url
lsof -p `pidof pidgin` | awk '{ print $9 }'|egrep `hostname` | grep -o ">[^:]\+:" | tr -d ":>" | while read line; do host $line; done;
This is sample output - yours may be different.
wg-in-f125.1e100.net has address 239.200.3.125
wg-in-f125.1e100.net has address 239.12.3.125
wg-in-f125.1e100.net has address 173.194.78.125
wg-in-f125.1e100.net has address 239.220.3.125
baymsg1020225.gateway.edge.messenger.live.com has address 64.4.61.175
jabber-02-01-snc7.tfbnw.net has address 69.171.227.26
baymsg1020206.gateway.edge.messenger.live.com has address 64.4.61.156
egrep '.*(("STATUS)|("HEAD)).*' http_access.2012.07.18.log | awk '{sum+=$11; ++n} END {print "Tot="sum"("n")";print "Avg="sum/n}'
This is sample output - yours may be different.
Tot=134020202(15201)
Avg=8816.54
Depending on your Apache access log configuration you may have to change the sum+=$11 to previous or next awk token.
Beware, usually in access log last token is time of response in microseconds, penultimate token is size of response in bytes. You may use this command line to calculate sum and average of responses sizes.
You can also refine the egrep regexp to match specific HTTP requests.
egrep 'ServerAlias|ServerName' /etc/apache2/sites-enabled/*.conf | awk '{printf "%s\t%s\n",$2,$3}' | sed 's/www.//' | sort | uniq
This is sample output - yours may be different.
Get a list of all the unique hostnames from the apache configuration files. Handy to see what sites are running on a server. When i saw the command i had some ideas to make it shorter. Here is my version.
tcpdump port http or port ftp or port smtp or port imap or port pop3 -l -A | egrep -i 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|username:|password:|login:|pass |user ' --color=auto --line-buffered -B20
This is sample output - yours may be different.
.{D.ezENPOST /users/register HTTP/1.1
Host: www.commandlinefu.com
...
Referer: http://www.commandlinefu.com/users/register
...
Content-Type: application/x-www-form-urlencoded
Content-Length: 147
username=jseidl&password=MASKED&password-confirmation=MASKED&email-address=MASKED%MASKED.MASKEDhomepage=MASKED&submit=Sign+me+up
Simple TCPDUMP grepping for common unsafe protocols (HTTP, POP3, SMTP, FTP)
shorty () { curl -s https://www.googleapis.com/urlshortener/v1/url\?key\=API_KEY -H 'Content-Type: application/json' -d '{"longUrl": "'"$1"'"}' | egrep -o 'http://goo.gl/[^"]*' }
This is sample output - yours may be different.
shorty http://stackoverflow.com/questions/8903222/using-curl-to-send-json-within-a-bash-script
http://goo.gl/UePvn
First get a api key for google url shortner from here https://developers.google.com/url-shortener/
Then replace the API_KEY in the command
find . -name unit-test -o -name '*.c' -o -name '*.cpp' | egrep -v "unit-test|android"
This is sample output - yours may be different.
Very useful for finding all the source code that should be compiled.
false; while [ $? != 0 ]; do apg -c /dev/urandom -n1 -E oOlL10 | egrep '^[[:alnum:]]+$'; done
This is sample output - yours may be different.
lynx -dump http://www.cooks4arab.com | awk '/http/{print $2}' | egrep "^https{0,1}"
This is sample output - yours may be different.