Using tail to follow and standard perl to count and print the lps when lines are written to the logfile.
When Ldapsearch queries an Active directory server, all the dates are shown using a timestamp of 18 digits. This perl regexp decodes them in a more human friendly notation. 11644473600 corresponds to some microsoft epoch. Show Sample Output
Reads stdin, and outputs each line only once - without sorting ahead of time. This does use more memory than your system's sort utility.
Shows the path if the module is installed or exit quietly (to simply avoid the 'No documentation found' msg). Show Sample Output
It uses the following GNU grep options: "-o" which shows only the matching part of the line and "-P" which allows the use of Perl regular expressions. Show Sample Output
Good for summing the numbers embedded in text - a food journal entry for example with calories listed per food where you want the total calories. Use this to monitor and keep a total on anything that ouputs numbers. Show Sample Output
This pipeline will find, sort and display all files based on mtime. This could be done with find | xargs, but the find | xargs pipeline will not produce correct results if the results of find are greater than xargs command line buffer. If the xargs buffer fills, xargs processes the find results in more than one batch which is not compatible with sorting. Note the "-print0" on find and "-0" switch for perl. This is the equivalent of using xargs. Don't you love perl? Note that this pipeline can be easily modified to any data produced by perl's stat operator. eg, you could sort on size, hard links, creation time, etc. Look at stat and just change the '9' to what you want. Changing the '9' to a '7' for example will sort by file size. A '3' sorts by number of links.... Use head and tail at the end of the pipeline to get oldest files or most recent. Use awk or perl -wnla for further processing. Since there is a tab between the two fields, it is very easy to process. Show Sample Output
random(6) - random lines from a file or random numbers
This method will also convert mac line endings.
This command will give you the detailed information about the installed perl modules i.e. installed path, Link type, version, files etc. Show Sample Output
This command turns a multi-line file into a single line joined with <SOMETEXT>. To skip blank lines, use:
perl -pe '(eof()||s/^\s*$//)||s/\n/<SOMETEXT>/g' file.txt
Show Sample Output
If you've ever tried "grep -P" you know how terrible it is. Even the man page describes it as "highly experimental". This function will let you 'grep' pipes and files using Perl syntax for regular expressions. The first argument is the pattern, e.g. '/foo/'. The second argument is a filename (optional). Show Sample Output
required packages: curl, xml2, html2text command is truncated, see 'sample output' Show Sample Output
Print environment (system) information using Perl.
Just another FizzBuzz in Perl. Show Sample Output
Using perl and tput, show all the colors with numbers that your actual $TERM can handle.
If want to remove the numbers at beginning of new line, it should be something like this:
perl -E 'say `tput setb $_`," "x `tput cols`, `tput sgr0` for 0 .. (`tput colors` - 1)'
There was another line that was dependent on having un-named screen sessions. This just wouldn't do. This one works no matter what the name is. A possible improvement would be removing the perl dependence, but that doesn't effect me.
When you have one of those (log)files that only has epoch for time (since no one will ever look at them as a date) this is a way to get the human readable date/time and do further inspection. Mostly perl-fu :-/
Requires Net::Twitter. Just replace the double quoted strings with the appropriate info.
**NOTE** Tekhne's alternative is much more succinct and its output conforms to the files actual contents rather than with white space removed My command on the other hand uses bash process substitution (and "Minimal" Perl), instead of files, to first remove leading and trailing white space from lines, before diff'ing the streams. Very useful when differences in indentation, such as in programming source code files, may be irrelevant Show Sample Output
This is a naive way of finding source code comments in source code files that use C-like comments: // and /*...*/
Randomizes a file. The opposite of sort is sort -R!
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: