* ps -ef # list running processes * grep string * pull the process names from 8th field * cut and delimiter '/' * print 4th field * get rid of trailing grep * for loop killall -9 $i which is the process name Show Sample Output
find . -maxdepth 1 -iname ".*" | awk 'NR >= 2' Can be used to list only dotfiles without . nor .. Show Sample Output
After this command you can review doit.sh file before executing it. If it looks good, execute: `. doit.sh`
Muestra el crecimiento de un archivo por segundo. Cambia el texto "FILE" por el nombre del archivo a monitorear. Comando LS + AWK Show Sample Output
changes the PS1 to something better than default. [username.hostname.last-2-digits-of-ip] (current directory) Show Sample Output
Can pipe to tail or change the awk for for file size, groups, users, etc. Show Sample Output
Useful for removes a package and its depends, for example to remove the gnome desktop environment, also configuration files will be removed, you should be carefully and sure that you want to do this. Show Sample Output
This command might not be useful for most of us, I just wanted to share it to show power of command line. Download simple text version of novel David Copperfield from Poject Gutenberg and then generate a single column of words after which occurences of each word is counted by sort | uniq -c combination. This command removes numbers and single characters from count. I'm sure you can write a shorter version. Show Sample Output
Well this can come handy , when you don't feel like playing with pid rather if you know the process name say "firefox",it would kill it.The script given below would kill the process with its name given as first parameter , though not robust enough to notify that process doesn't exist , well if you know what you are doing that's wouldn't be a problem.:) ---- killhim.sh ---- #!/bin/bash ps -u $USER |grep $1 | awk '{ print $1}'| xargs kill ----
manda la salida de un comando hacia un servicio de paste y coloca la url de ese paste en el portapapeles
Build an awk array with all commands and then select a random one at the end. This avoids spawning extra processes for counting with wc or generating random numbers. Explicitly call /bin/ls to avoid interactions with aliases.
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
netstat has two lines of headers: Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State Added a filter in the awk command to remove them
Quick and dirty one-liner to get the average ping(1) time from a server. Show Sample Output
# define user pid to kill PID=httpd ; # kill all pids ps aux | grep $PID | grep -v grep | awk '{print $2}' | xargs kill -9 Show Sample Output
Get the first IPv4 address of an interface Show Sample Output
Oneliner to get domain names list of all existing domain names (from wikipedia) Show Sample Output
Did some research and found the previous command wrong, we don't kill a zombie but its parent. Just made some modifcation to khashmeshab's command.
This finds a process id by name, but without the extra grep that you usually see. Remember, awk can grep too!
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: