views:

118

answers:

2

In comments in source code (especially older code), one may see in the header comments the filename, date and perhaps other info in this special format:

/* @(#)fdlibm.h 1.5 95/01/18 */

(see also: http://www.google.com/codesearch?q=%22%40%28%23%29%22&hl=en&btnG=Search+Code )

This is quite similar (or perhaps related?) to the RCS-like string "$Id$" ($Header$, etc). I thought the "file" command-line utility or similar would look for these "magic" strings in the source, but that's not the case.

Is there a utility / program (other than 'grep'!) that actually uses these strings prefixed by "@(#)"?

+8  A: 

That would be SCCS, a mesozoic-era revision control system. That magical string is used by the what command.

Jonathan Feinberg
A: 

"what" (from SCCS) is the correct answer indeed (thanks Jonathan). I was hoping to find a modern cross-platform version of "what" that could even work for binary files (like "strings xfile | grep..."). Presently it seems that "what" is typically still only found on Solaris.

Here's an example...

$ cat foobar.c
/*
* @(#) foobar.c  9.04 (mn) 10/29/2009
*/
static const char * foobar = "@(#) some string";
int main(int argc, char *argv[]) { }

$ gcc foobar.c

$ what a.out  foobar.c
a.out:
         some string
        SunOS 5.10 s10_69 December 2004
foobar.c:
         foobar.c  9.04 (mn) 10/29/2009
         some string

$ strings a.out | grep '@(#)'
@(#) some string

ps: I tried posting this as a comment to Jonathan's correct answer, but the source code formatting didn't quite work out.

michael_n
If you found my answer helpful, you can "accept" it.
Jonathan Feinberg
Thanks for the reminder. Clicking the little hollow arrow (turning it green) isn't as straight-forward as the implementor probably thought it was. Actual text saying "Accept this answer" would be a slightly better Human Interface design decision, in case anyone is listening (ahem).
michael_n