A fast command-line utility to display configuration files and code without comments or blank lines. Perfect for quickly checking which settings are actually enabled in config files.
- Fast - written in C with single-pass processing
- Smart defaults - recognizes all common comment styles automatically
- Flexible - customize comment characters, keep blank lines, strip inline comments
- Simple - single C file, no dependencies beyond libc
#- Shell, Python, Ruby, YAML, Perl, Make, Bash, etc.//- C, C++, Java, JavaScript, Go, Rust, Swift, etc.;- Assembly, INI files, Lisp, Scheme--- SQL, Lua, Haskell, Ada
git clone https://github.com/cybercdh/cnc.git
cd cnc
make
sudo make installgit clone https://github.com/cybercdh/cnc.git
cd cnc
make
make install PREFIX=~/.localTip: If another
cncexists in yourPATH, install under a different name by editing the binary name after build, or use the full path.
cnc [file]
# If file is omitted or '-', reads from stdin# View SSH config without comments
cnc /etc/ssh/sshd_config
# View nginx config, keeping blank lines for readability
cnc -b /etc/nginx/nginx.conf
# Remove inline comments from a shell script
cnc -i script.sh
# Fast mode for files with only # comments
cnc -s /etc/fstab
# Custom comment character for INI files
cnc -c ';' config.ini
# Multiple custom comment types
cnc -c '#,;' app.conf
# Use with pipelines / stdin
cat sshd_config | cnc -i --h, --help Show help message
-v, --version Show version
-b, --keep-blank Keep blank lines (default: remove them)
-i, --inline Also remove inline comments (after code)
-c, --char CHARS Override comment characters (comma-separated)
-s, --simple Only remove # comments (fastest)
$ cat /etc/ssh/sshd_config
# This is the sshd server system-wide configuration file.
# See sshd_config(5) for more information.
# Network settings
Port 22
#Port 2222
# Authentication
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no # Disable password auth
# Logging
SyslogFacility AUTH
LogLevel INFO$ cnc /etc/ssh/sshd_config
Port 22
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no # Disable password auth
SyslogFacility AUTH
LogLevel INFO$ cnc -i /etc/ssh/sshd_config
Port 22
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
SyslogFacility AUTH
LogLevel INFO- Quick config inspection - See what's actually configured without scrolling through comments
- Config diffing - Compare actual settings between files
- Debugging - Quickly identify active configuration directives
- Documentation - Extract actual settings for documentation
- DevOps - Parse configs in scripts without comment noise
Ever tried to check what's actually enabled in /etc/ssh/sshd_config or a massive nginx config, only to scroll through hundreds of lines of comments? cnc solves this by showing you just the active configuration.
It's like cat, but smarter about config files.
| Tool | Pros | Cons |
|---|---|---|
grep -v '^#' |
Simple, no install | Misses indented comments, only works for # |
sed '/^#/d' |
Fast | Misses indented comments, requires pattern knowledge |
| cnc | Handles all comment types, removes blank lines, fast | Requires compilation |
cnc is written in C for speed. On a 7MB config file:
cat (baseline): 6ms
cnc: 142ms
For typical config files (a few KB), execution is instant.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
make # Build cnc
make test # Run tests
make clean # Remove binary
make install # Install to /usr/local/bin (or set PREFIX)MIT License - see LICENSE file for details.
- Rewritten in C for ~2x performance improvement
- Single-pass processing with buffered I/O
- Initial release
- Support for #, //, ;, -- comment styles
- Inline comment removal with -i flag
- Custom comment character support
- Keep blank lines option
Created for sysadmins and developers who love clean config files.