More UNIX tools
C Programming Tools
cflow - produce flow graph of C code
Usage:
$ cflow -I../include -DNDEBUG linklist.c
lint - C program checker, produces warnings of potentially bad code contructions
Usage:
$ lint -I../include -DNDEBUG linklist.c
C Source Browsing Tools
ctags - creates tags file for functions and typedefs
ctags [options] file(s)
Usage:
$ ctags *.[ch] # builds tags file for *.[ch] files
exuberant ctags - creates tags file for functions, structures, typedefs, defines, enumerations, constants, global variables
e_ctags [options] file(s)
--help show all options
--langmap=<map> mapping of langguage to file suffixes
-L <file> <file> containss source file names - means use stdin
-e build for Emacs
Usage:
$ e_ctags --langmap=c:c.h.pc # C files can end in c, h, or pc
$ e_ctags *.[ch] ../common/*.[ch] # build tags for source in . and ../common
How to use tags in vi - run vi in directory which contains file named "tags"
Command line usage:
$ vi -t tagname # goto tag
Usage in vi:
<ctrl>] goto tag at cursor
<ctrl>t return to previous cursor location
:ta tagname goto tag
ID tools - for finding all occurrences of names. Search tools use ID file which must be in current directory or a parent directory.
mkid [dir(s)] - build ID database
gid name - grep files containing name
eid name - edit files containing name
Usage:
$ mkid ../common . # build ID file
$ gid perror # show perror occurrences
$ eid max_errors # edit file with max_errors occurrences
Generic Search Tools
grep/egrep/fgrep - search for patterns
grep [options] expression file(s)
fgrep [options] string file(s)
egrep [options] reg-expression file(s)
-i ignore case
-v invert search
-n print line numbers
xargs - runs a command on files read from stdin
Usage:
$ echo ../src/* | xargs grep "Error"
$ find . -name '*.[ch]' -print |\
xargs grep "Cannot"
Other Information Extraction Tools
ldd - lists shared libraries
Usage:
$ ldd /usr/bin/ls
file - identifies file contents using magic numbers (/etc/magic)
Usage:
$ file *
strings - finds strings in a file
Usage:
$ strings gmdjan