regex to match an ip Show Sample Output
It's not a big line, and it *may not* work for everybody, I guess it depends on the detail of access_log configuration in your httpd.conf. I use it as a prerotate command for logrotate in httpd section so it executes before access_log rotation, everyday at midnight.
You'll need to install proctools. MacPorts and Fink have this if you're running Mac OS X, check your Linux distribution's repositories if it isn't installed by default. Show Sample Output
hb(){ sed "s/\($*\)/`tput setaf 2;tput setab 0;tput blink`\1`tput sgr0`/gI"; }
hb blinks, hc does a reverse color with background.. both very nice.
hc(){ sed "s/\($*\)/`tput setaf 0;tput setab 6`\1`tput sgr0`/gI"; }
Run this:
command ps -Hacl -F S -A f | hc ".*$PPID.*" | hb ".*$$.*"
Your welcome ;)
From my bash profile - http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Show Sample Output
This is what we use. You can grep -v 127.0.0.1 if you wish.
Randomize GNU grep's colors 31-36 excluding black and white.
If both file1 and file2 are already sorted: comm -13 file1 file2 > file-new
This is a little trickier than finding the last Sunday, because you know the last Sunday is in the first position of the last line. The trick is to use the NF less than or equal to 7 so it picks up all the lines then grep out any empty lines. Show Sample Output
Function that searchs for process by its name:
* Shows the Header for reference
* Hides the process 'grep' from the list
* Case sensitive
The typical problem with using "ps | grep" is that the grep process shows up the in the output.
The usual solution is to search for "[p]attern" instead of "pattern".
This function turns the parameter into just such a [p]attern.
${1:0:1} is the first character of $1
.
${1:1} is characters 2-end of $1
Show Sample Output
Displays live hosts on the same network as the local machine with their hostnames and IP addresses.
This command is IPv6 and multiple network adapter safe and does not rely on awk or sed, however it requires the "nmap" package installed. Might not work on OSX.
Example alias for shell startup file:
alias livehosts='nmap -sP "$(ip -4 -o route get 1 | cut -d " " -f 7)"/24 | grep report | cut -d " " -f 5-'
Show Sample Output
This will, for an application that has already been removed but had its configuration left behind, purge that configuration from the system. To test it out first, you can remove the last -y, and it will show you what it will purge without actually doing it. I mean it never hurts to check first, "just in case." ;)
no need to use grep.
We can put this inside a function:
fxray() { curl -s http://urlxray.com/display.php?url="$1" | grep -o '<title>.*</title>' | sed 's/<title>.*--> \(.*\)<\/title>/\1/g'; };
fxray http://tinyurl.com/demo-xray
Show Sample Output
Remove all arquives except the list. Can't have space between the commas. Show Sample Output
Original submitter's command spawns a "grep" process for every file found. Mine spawns one grep with a long list of all matching files to search in. Learn xargs, everyone! It's a very powerful and always available tool.
Good for finding outdated timthumb.php scripts which need to be updated, anything over 2.0 should be secure, below that timthimb is vulnerable and can be used to compromise your website. Show Sample Output
After this command you can review doit.sh file before executing it. If it looks good, execute: `. doit.sh`
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.
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
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: