d (delete) command removes files from existing archives without extracting or recreating the entire archive.
Syntax
Description
The delete command:- Removes specified files from archives
- Updates archive structure and indices
- Maintains archive integrity
- Supports pattern matching for bulk deletions
- Works with encrypted archives (requires password)
- Does not extract files
Common Options
Name of the archive to modify. Must already exist.
Files or patterns to delete from archive. Supports wildcards.Example:
*.tmp or logs/old.logProvide password for encrypted archives.Example:
-pMyPasswordRecurse subdirectories when matching patterns.
Include files matching pattern.Example:
-i!*.bakExclude files from deletion.Example:
-x!important.txtSpecify archive type (usually auto-detected).
Set working directory for temporary files.
Set output log level.
Examples
Delete a single file
Delete multiple files
Delete all files with specific extension
Delete files in a directory
Delete with pattern matching
Delete from encrypted archive
Delete except specific files
Delete with confirmation
Advanced Examples
Delete old log files
Delete all temporary files recursively
Delete specific directory
Delete files with verbose output
Delete from multiple archives
Safe delete (backup first)
Pattern Matching
Wildcards
*- Matches any characters?- Matches single character[abc]- Matches any character in brackets
Examples
Deleting from Different Archive Types
ZIP archive
RAR archive (if writable)
TAR archive
7z archive
Scripting Examples
Clean Temporary Files
Interactive Delete
Delete with Size Threshold
Delete Old Files by Date
Important Considerations
Archive Type Limitations
- 7z - Full delete support
- ZIP - Full delete support
- TAR - Full delete support
- RAR - Limited (depends on RAR version)
- GZIP/BZIP2 - Not supported (single-file compression)
Solid Archives
For solid archives (-ms=on):
- Deleting requires recompressing affected solid blocks
- Can be slower than non-solid archives
- May require significant temporary disk space
Encrypted Archives
- Password required for header-encrypted archives
- Password must match archive encryption
- Cannot delete from corrupted encrypted archives
Performance Tips
- Delete multiple files in one command - Faster than multiple delete operations
- Use patterns instead of individual files - More efficient
- Avoid frequent small deletions - Reorganize and recreate if needed
- Set working directory - Use
-wto control temp file location - Solid archives - Consider recreating instead of deleting
Comparison: Delete vs Recreate
Delete Command
- Faster for small deletions
- Preserves archive metadata
- Atomic operation
- Solid archives may need recompression
- Multiple deletions can fragment archive
Recreate Archive
- Can optimize compression
- Clean archive structure
- Can change compression settings
- Requires disk space
- Slower for small changes
- Temporary extraction needed
The delete command modifies the archive in place. Always keep backups of important archives before performing delete operations.
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success (files deleted) |
| 1 | Warning (some files not found) |
| 2 | Fatal error (archive corrupted or locked) |
| 7 | Command line error |
| 8 | Not enough memory |
Related Commands
- Add Command (a) - Add files to archives
- Update Command (u) - Update files in archives
- List Command (l) - View archive contents