Commands using egrep (204)

  • Provides a cleaner output plus some more details about the IP address. Also, a flaw was corrected where the URL provided the results in Spanish by default. Show Sample Output


    0
    function geoip() { curl -s "http://www.geoiptool.com/en/?IP=$1" | html2text | egrep --color "IP Address:|Country:|City:|Longitude:|Latitude:|Host Name:" }
    JohnQUnknown · 2011-10-25 04:49:25 0
  • Just use your system preinstalled file Show Sample Output


    0
    portnum() { egrep "[[:space:]]$*/" /etc/services; }
    unixmonkey26187 · 2011-10-07 16:38:29 0

  • 0
    lynx -dump http://www.anti-abuse.org/multi-rbl-check/ | grep ']' | awk -F\] '{ print $2 }' | sed '/^\[/d' | egrep -v ^[A-Z]
    audiopathix · 2011-09-30 03:52:29 0
  • Discover host and url of media files (ex. flv, mp4, m4v..). It locate the urls of audio and video files so that they can be recorded.


    -1
    sudo ngrep -lqi -p -W none ^get\|^post tcp dst port 80 -d eth0 | egrep '(flv|mp4|m4v|mov|mp3|wmv)'
    marste · 2011-09-18 06:33:36 3
  • Get all URLs from website via Regular Expression... You must have lynx installed in your computer to execute the command. --> lynx --dump "" | egrep -o "" - Must substitute it for the website path that you want to extract the URLs - Regular Expression that you wanna filter the website Show Sample Output


    0
    lynx --dump "http://www.google.com.br" | egrep -o "http:.*"
    felipelageduarte · 2011-09-05 01:12:15 0
  • If you make a mess (like I did) and you removed all the executable permissions of a directory (or you set executable permissions to everything) this can help. It supports spaces and other special characters in the file paths, but it will work only in bash, GNU find and GNU egrep. You can complement it with these two commands: 1. add executable permission to directories: find . type d -print0 | xargs -0 chmod +x 2. and remove to files: find . type d -print0 | xargs -0 chmod -x Or, in the same loop: while IFS= read -r -u3 -d $'\0' file; do case $(file "$file" | cut -f 2- -d :) in :*executable*|*ELF*|*directory*) chmod +x "$file" ;; *) chmod -x "$file" ;; esac || break done 3< <(find . -print0) Ideas stolen from Greg's wiki: http://mywiki.wooledge.org/BashFAQ/020


    0
    while IFS= read -r -u3 -d $'\0' file; do file "$file" | egrep -q 'executable|ELF' && chmod +x "$file"; done 3< <(find . -type f -print0)
    keymon · 2011-08-18 15:37:23 7

  • -1
    rm -R `ls | egrep -v 'dir1|dir2|file1'`
    killman · 2011-08-07 08:34:17 0
  • Advanced revision to the command 8776 . This revision follows symbolic links. The quotation-marks surrounding $(which $1) allows for graceful handling of errors ( ie. readlink does not complain incase 'which' command generates (null) output) Show Sample Output


    1
    whichpkg () { dpkg -S $1 | egrep -w $(readlink -f "$(which $1)")$; }
    b_t · 2011-07-17 13:39:56 0

  • 0
    egrep expr1\|expr2 file
    p01nt · 2011-07-14 14:51:17 0
  • to find occurances of expr1 OR expr2


    -3
    egrep '(expr1|expr2)' file
    evandrix · 2011-07-14 14:22:11 0
  • grep - Search file for character string Search for one or more strings in one or more files. Examples:- grep that myfile.txt Look for the string ``that'' in the file called ``myfile.txt'' and print out each line that matches. egrep -in "this|that" *.dat Extended grep search *.dat files for ``this'' or ``that'' case insensitive (-i) and where found print line number (-n) along with the line contents. Show Sample Output


    -5
    egrep -in "this|that" *.dat
    evandrix · 2011-07-06 09:42:26 0
  • This version builds on my command 8776 (Find the package a command belongs to on debian-based distros). So if you use that command to find package name then you could alternatively use following for package summary: function summpkg { dpkg -s $(whichpkg $1 | awk -F: '{print $1}'); } Show Sample Output


    0
    function summpkg { dpkg -s $(dpkg -S $1 | egrep -w $(which $1)$ | awk -F: '{print $1}') ; }
    b_t · 2011-07-05 23:06:37 0
  • Similar to command 7822, but handles errors gracefully. Show Sample Output


    0
    function whichpkg { dpkg -S $1 | egrep -w $(which $1)$; }
    b_t · 2011-07-05 22:56:48 0
  • Say your dependencies specified in your Makefile (or dates on your source files) is causing 'make' to skip some source-files (that it should not) or on the other other end, if it is causing make to always build some source-files regardless of dates of target, then above command is handy to find out what 'make' thinks of your date v/s target date-wise or what dependencies are in make's view-point. The egrep part removes the extra noise, that you might want to avoid. Show Sample Output


    1
    make -d | egrep --color -i '(considering|older|newer|remake)'
    b_t · 2011-06-03 01:55:08 1

  • 1
    egrep -v "^$|^#" file
    wincus · 2011-05-23 11:39:24 0
  • Shows updated status in a terminal window for connections to port '80' in a human-friendly form. Use 'watch -n1' to update every second, and 'watch -d' to highlight changes between updates. If you wish for status updates on a port other than '80', always remember to put a space afterwards so that ":80" will not match ":8080". Show Sample Output


    7
    watch 'netstat -anptu |egrep "^Proto|:80 "'
    Mozai · 2011-05-18 15:05:52 4

  • 0
    alias screenr='screen -r $(screen -ls | egrep -o -e '[0-9]+' | head -n 1)'
    yababay · 2011-05-12 05:44:39 2
  • you can also use cut instead of awk. less powerful but probably faster. ;)


    3
    egrep -ie "<*HREF=(.*?)>" index.html | cut -d "\"" -f 2 | grep ://
    fanfani · 2011-03-29 18:20:50 1

  • -1
    svn st | grep -e [MA] | egrep -ve '.project|.classpath|.properties|.sh|.number' | awk -F' ' '{ print $2}' | xargs svn ci -m "message"
    drunkcoder · 2011-03-10 15:32:36 3

  • -1
    egrep '__NR_' /usr/include/asm/unistd_`getconf -a | awk '$1~/^WORD/{print $2}'`.h | sed -e 's/^#define __NR_//' | column -t
    cicatriz · 2011-03-04 15:09:40 0
  • Look mah! All pipes


    1
    ps ax | egrep "*.exe|*exe]" | awk '{ print $1 }' | xargs kill
    coffeeaddict_nl · 2011-03-01 09:48:47 0
  • This command kills all wine instances and each EXE application working on a PC. Here is command info: 1) ps ax > processes = save process list to file named "processes" (we save it because we don't wont egrep to be found in the future) 2) cat processes | egrep "*.exe |*exe]" = shows the file "processes" and after greps for each *.exe and *exe] in it 3) | awk '{ print $1 }' > pstokill = saves processes PID's to file "pstokill" using awk filter 4) kill $(cat pstokill) = kills each PID in file pstokill, which is shown by cat program 5) rm processes && rm pstokill = removes temporary files Show Sample Output


    -4
    ps ax > processes && cat processes | egrep "*.exe |*exe]" | awk '{ print $1 }' > pstokill && kill $(cat pstokill) && rm processes && rm pstokill
    sxiii · 2011-02-26 16:13:58 2
  • The above one liner can be used to determine what card/driver is Xorg currently using. For additional information, see http://goo.gl/mDnWu Show Sample Output


    -1
    egrep -i " connected|card detect|primary dev" /var/log/Xorg.0.log
    axelabs · 2011-02-24 18:04:04 0
  • The dates in the output are Start Date, End Date, Days Remaining in warranty, respectively. This will only work if you are running it on a dell machine. You can substitute the dmidecode command with a service tag if you are not using a dell. Also, you have to either allow your user to run sudo dmidecode with no password or run this command as root. Show Sample Output


    -2
    curl -Ls "http://support.dell.com/support/DPP/Index.aspx?c=us&cs=08W&l=en&s=biz&ServiceTag=$(dmidecode -s system-serial-number)"|egrep -i '>Your Warranty<|>Product Support for'|html2text -style pretty|egrep -v 'Request|View'|perl -pane 's/^(\s+|\})//g;'
    din7 · 2011-02-18 22:29:05 0
  • Will automatically take the size of the file but longer, usefull only if in an function.


    1
    dd if=FILE | pv -s $(stat FILE | egrep -o "Size: [[:digit:]]*" | egrep -o "[[:digit:]]*") | dd of=OUTPUT
    andrepuel · 2011-02-09 22:21:06 1
  • ‹ First  < 2 3 4 5 6 >  Last ›

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: