Same as the rest, but handle IPv6 short IPs. Also, sort in the order that you're probably looking for. Show Sample Output
on some distro's you have to replace "BogoMIPS" with "bogomips". Show Sample Output
credit shall fall to this for non-gzipped version: https://gist.github.com/marcanuy/a08d5f2d9c19ba621399 Show Sample Output
capture 2000 packets and print the top 10 talkers
List all open files of all processes.
.
find /proc/*/fd
Look through the /proc file descriptors
.
-xtype f
list only symlinks to file
.
-printf "%l\n"
print the symlink target
.
grep -P '^/(?!dev|proc|sys)'
ignore files from /dev /proc or /sys
.
sort | uniq -c | sort -n
count the results
.
Many processes will create and immediately delete temporary files.
These can the filtered out by adding:
... | grep -v " (deleted)$" | ...
Show Sample Output
No need for sort Show Sample Output
worse alternative to ctrl+r: grep the history removing duplicates without sorting (case insensitive search). Show Sample Output
Sometimes things break. You can find the most recent errors using a combination of journalctl, along with the classic tools sort and uniq Show Sample Output
If we want files with more than one extension, like .tar.gz, only appear the latest, .gz:
ls -Xp /path/to/dir | grep -Eo "\.[^./]+$" | uniq
Show Sample Output
Gives the same results as the command by putnamhill using nine less characters.
count connections, group by IP and port
Detect duplicate UID in you /etc/passwd (or GID in /etc/group file). Duplicate UID is often forbidden for it can be a security breach. Show Sample Output
See who is using a specific port. Especially when you're using AIX. In Ubuntu, for example, this can easily be seen with the netstat command. Show Sample Output
useful to count events in logs Show Sample Output
useful to count events in logs @see: http://www.commandlinefu.com/commands/view/10327/report-summary-of-string-occurrence-by-time-period-hour#comment Show Sample Output
depends on date format locale ... Show Sample Output
the
find -printf "%f\n" prints just the file name from the given path. This means directory paths which contain extensions will not be considered.
Show Sample Output
Uniq command is mostly used in combination with sort command, as uniq removes duplicates only from a sorted file. i.e In order for uniq to work, all the duplicate entries should be in the adjacent lines. Show Sample Output
Count on a specific port (80) - FreeBSD friendly. Show Sample Output
This is a modified version of the OP, wrapped into a bash function. This version handles newlines and other whitespace correctly, the original has problems with the thankfully rare case of newlines in the file names. It also allows checking an arbitrary number of directories against each other, which is nice when the directories that you think might have duplicates don't have a convenient common ancestor directory.
If you have GNU findutils, you can get only the file name with
find /some/path -type f -printf '%f\n'
instead of
find /some/path -type f | gawk -F/ '{print $NF}'
Show Sample Output
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: