Showing posts with label unix_utilities. Show all posts
Showing posts with label unix_utilities. Show all posts

Saturday, December 14, 2013

"Useless Use of Cat" Award, "Useless Use of …" Award, …


Rather reasonable and entertaining reading as the same time.
In the future I will certainly refer people to his page, whenever I will happen to find an opportunity.

Wednesday, December 4, 2013

AIX moans: "Cannot open or remove a file containing a running program"


I came across this phenomenon in various contexts on AIX. 
It really sounds like "text file busy" from the old Unix days.

Looks like the guys who misuse this error message for there miserable situations actually mean "cannot open or remove a file". I call this capturing.

Looks like some variants of the "copy" utility (like CPAN File::Copy) use this error message instead of "no such file or directory". Maybe this happens in concurrent environments / situations, where a file disappears between the call to File::Copy and the actual kernel "open". Once "open" has a file handle, the inode access counter gets incremented, and the file cannot really disappear any longer, as long as it remains open ie. did not get closed again.

To be continue …

Wednesday, October 23, 2013

created utility "cvsgrep" from "rcsgrep" shipping with O'Reilly's "Unix Power Tools" (the code TAR ball)

Derived cvsrevs from rcsrevs, and cvsgrep from rcsgrep. This is really nice!! Imagine this:
$ cvsgrep -a SEARCHME files


I knew,  rcsgrep and sisters would be very, very useful.

svngrep should be quite useful as well.

Wednesday, October 9, 2013

displaying files (on a UNIX command line), each file together with its names

displays each file with its name before its content:
$ head -999 file-a file-b file-c

displays each file with its name before each line of its content:
$ pipegrep '' cat file-a file-b file-c

Search the web for pipegrep, if you are interested in it! It is written in one word.

how to easily display a base64 encoded file

I wondered, how I could achieve that on various Unix platforms, and I ran the following command on my Linux box:

$ man -k base64
base64 (1)           - base64 encode/decode data and print to standard output
MIME::Base64 (3pm)   - Encoding and decoding of base64 strings

Right the utility base64 (beloning to GNU coreutils) would do it, if it were broadly available; on AIX you can't expect GNU coreutils to be installed.
The MIME::Base64 man page shows a nice perl one-liner making use of a perl module, which is rather likely to be installed:

$ perl -MMIME::Base64 -ne 'print decode_base64($_)'

Wednesday, September 25, 2013

O'Reilly Media book: Unix Power Tools, 3rd Edition (2002)


a couple of nice utilities from their sample code:
  • rcsgrep, rcsegrep, rcsfgrep - check out files and grep/egrep/fgrep them – is there somthing similar for subversion etc.?
Update 2013-10-23:
Derived cvsrevs from rcsrevs, and cvsgrep from rcsgrep. This is really nice!! Imagine this:
$ cvsgrep -a SEARCHME files

do you remember "pipegrep" from a rather old Camel Book?

[Chapter 27] 27.13 More grep-like Programs Written in Perl (an outdated but still useful "Unix Power Tools" edition somewhere on a web-server discusses it)

The pipegrep program greps the output of a series of commands. The difficulty with doing this using the normal grep program is that you lose track of which file was being processed. This program prints out the command it was executing at the time, including the filename. The command, which is a single argument, will be executed once for each file in the list. If you give the string {} anywhere in the command, the filename will be substituted at that point. Otherwise the filename will be added on to the end of the command. This program has one option, -l, which causes it to list the files containing the pattern.

Follow the above link for a nice example!

I remembered the pipegrep utility today, because I came across a task …

Update 2013-10-17:

Tuesday, September 10, 2013

yet another Perl power tool: ack - grep-like text finder

ack - grep-like text finder - metacpan.org - Perl programming language

added "Perl Power Tools" to the PPT "disambiguation page" on the English wikipedia

en.wikipedia.org/wiki/PPT

I am curious, how long this entry will survive there. It's actually not referring to an existing article on the Perl Power Tools. It's just meant to tell "the reader", hey, there are these nice Perl Power Tools out there, and they also get abbreviated as PPT.

Well, yes, I could create a wikipedia stub page, but it would only have these 2 links:

And maybe some short text with like 30 words from the first of these 2 links.

But for how long would this stub article survive on wikipedia?

Tuesday, June 11, 2013

how to sort files by content

Same content, different names of 2 or more files –– how to identify the duplicates?

Use check sum utilities (like chksum, md5sum, sha1sum, …)  for this, and sort on their output!

Friday, June 7, 2013

linux - How to 'grep' a continuous stream - Stack Overflow

linux - How to 'grep' a continuous stream - Stack Overflow

  • a had never heard of stdbuf before
  • AIX grep has -u
  • GNU grep has --line-buffered, its -u is not the same as AIX grep's

Monday, April 29, 2013

logcheck – scans your logfiles and warns you

Dependencies and restrictions:
  • logcheck depends on logtail
  • logtail runs on exactly one file …
  • … and only once on that file, as it keeps a sister file called logfile.offset
  • improving this should actually be "easy", e.g. keeping a sister file called logfile.offset.user

Pros:
  • abstracting resp. filtering log files like /var/log/messages
  • this happens "realtime" i.e. instantly
Cons:
  • the results get to you resp. a whole crowd via e-mail – isn't that a little excessive regarding the resources necessary to look at the output?
  • if you already have a utilty in place, that filters daily chunks of log files, this is 
Ideas / inspirations taken from here:
  • the output could actually go to another log file, that you may want to "logtail" or "tail -f" as to your needs

Wednesday, March 20, 2013

munpack = MIME unpack – a utility to unpack messages in MIME or split-uuencode format

munpack(1) - Linux man page

If you need to deal with MIME attachements of an e-mail message within a shell script, this has been the tool for this purpose for ages now.

Sunday, January 20, 2013

patch is a Unix program that updates text files according to instructions … - Wikipedia, the free encyclopedia

patch (Unix) - Wikipedia, the free encyclopedia

The article includes "usage examples", and it refers to another article named "diff variations", which is quite useful to read for better understanding of the matter.

"Somebody" requested me to test critical software and to keep the number of changes to the software itself minimal. He suggested, I should find a way of creating the changes, that I think are necessary to ease my testing, automatically, ie. to sort of "patch" the original file. After I had gotten told that a couple of times, it clicked in my upper storey. Why not use the homonymous UNIX utility? This may not be very innovative, but it somehow enraptured me.

On AIX patch and "diff -u" don't seem to work together.

Thursday, November 8, 2012

PPT = Perl Power Tools: "Unix Reconstruction Project"


Welcome to the Unix Reconstruction Project.
Our goal is quite simply to reimplement the classic Unix command set in pure Perl, and to have as much fun as we can doing so.

I would really love to have a few more utilities in that collection:
Yes, the GNU coreutils do certain things much, much better, but still … – yet: you can install PPT privately and with a rather small footprint, which makes them rather suitable in certain corporate environments. 

Just a few goodies:
  • tcgrep lets you traverse directory trees – more or less like ack (see below!)
  • tail lets you follow multiple files simultaneously
Parts of the collection with a separate life outside the collection:
A few utilities, that are not formally a part of this collection:

Wednesday, May 23, 2012

O'Reilly Media book: Macintosh Terminal Pocket Guide

Macintosh Terminal Pocket Guide:
Every Mac user knows how to work with windows and icons, but there is a wonderful application behind the scenes—the Terminal—that provides tremendous additional power. With this handy guide, you’ll learn valuable commands that remove limits and open doors that many Mac users don’t know exist.