LinuxCommandLibrary

lid.idutils

TLDR

List all tokens and their file locations in the ID database

$ lid
copy

Find files containing a specific token
$ lid [token]
copy

Find tokens matching a pattern, ignoring case
$ lid [[-i|--ignore-case]] [token]
copy

Find tokens matching an extended regex
$ lid [[-r|--regexp]] "[pattern]"
copy

Output matching lines in grep-style format
$ lid [[-R|--result]] grep [token]
copy

Find tokens that appear only once (useful for finding unused definitions)
$ lid [[-F|--frequency]] 1
copy

SYNOPSIS

lid [OPTION...] [ID-FILE] IDENTIFIER

PARAMETERS

-i, --ignore-case
    Ignore case distinctions in searches

-l, --list
    List matching lines instead of just files

-R REGEXP, --regexp=REGEXP
    Search using REGEXP instead of literal identifier

-s, --statistics
    Print statistics about the search

-v, --verbose
    Verbose output mode

--help
    Display help and exit

--version
    Output version information and exit

DESCRIPTION

The lid command, part of the GNU id-utils package, is a powerful tool for quickly searching an ID database to find files containing specific identifiers, such as function names, variables, or symbols in source code.

It relies on a pre-built ID index file (typically named ID), created using the mkid command, which indexes all tokens in a set of files for rapid lookups.

Unlike general-purpose tools like grep, lid provides indexed, token-aware searches that are significantly faster on large codebases, making it ideal for software development, code maintenance, and auditing.

Basic usage involves specifying an identifier after options, with the database file optional (defaults to ID in the current directory). Output lists matching file paths, and options allow listing matching lines, case-insensitive searches, regex patterns, statistics, and more.

lid excels in scenarios requiring precise symbol location across projects, supporting efficient navigation in C, C++, Java, or any textual codebase. It's lightweight, with minimal runtime overhead once indexed.

CAVEATS

Requires a pre-built ID database (via mkid); not installed by default on most distributions. Searches are token-based, so may miss substrings without exact matches unless using -R.

ID DATABASE

Central index file named ID containing tokenized file contents. Build with mkid -o ID file-list for custom setups.

Update incrementally with mkid --update.

PERFORMANCE TIPS

Best for large static projects; rebuild ID after file changes. Faster than grep -r by orders of magnitude on indexed data.

HISTORY

Developed by Dean Roehrich in 1991 as part of id-utils for fast code searching. Adopted into GNU in 1996, with ongoing maintenance for modern systems.

SEE ALSO

mkid(1), gid(1), mid(1), fid(1)

Copied to clipboard