This document describes the wildcard and Linux notation support added to the PureSimulator virtual terminal.
The asterisk matches zero or more characters in filenames and paths.
Examples:
ls *.ppkg- Lists all files ending with.ppkgls file*- Lists all files starting with "file"ls /dev/sd*- Lists all devices starting with "sd" (e.g., sda1, sdb1)ls *test*.txt- Lists all.txtfiles containing "test"
The question mark matches exactly one character in filenames and paths.
Examples:
ls file?.txt- Matches file1.txt, fileA.txt, but not file10.txtls test?.log- Matches test1.log, testa.log, etc.ls /dev/sd?1- Matches sda1, sdb1, sdc1, etc.
Represents the current working directory.
Examples:
ls .- Lists files in the current directorycp /mnt/file.txt .- Copies file.txt to the current directory
Represents the parent directory of the current working directory.
Examples:
cd ..- Changes to the parent directoryls ..- Lists files in the parent directorycp ../file.txt .- Copies a file from the parent directory to current
The wildcard support has been implemented in the following components:
- Added
GetMatchingFiles(string pattern)method for pattern matching - Added
WildcardMatch(string text, string pattern)for*and?support
- Enhanced
MatchesWildcard()to support both*and? - Updated
FindAndListFiles()to handle wildcard patterns in file paths - Added support for wildcards in
/dev/directory listings
- Updated
FindFilesRecursive()to use wildcard matching - Added
WildcardMatch()method for file searching - Path normalization already supports
.and..throughNormalizePath()
- Added
HandleWildcardLs()for ls command with wildcards - Added
WildcardMatchPublic()helper method - Enhanced
HandleLsCommand()to detect and process wildcards
ls *.ppkg # List all .ppkg files
ls /dev/sd* # List all sd devices
ls file?.txt # List files matching pattern
ls /mnt/* # List all files in /mntcp /mnt/*.ppkg . # Copy all .ppkg files from /mnt to current dir
cp ../file.txt . # Copy from parent directoryDouble-tap Tab to autocomplete filenames (existing functionality). The autocomplete works with partial filenames and paths.
The wildcard matching uses a backtracking algorithm that:
- Matches
?to exactly one character - Matches
*to zero or more characters - Handles multiple wildcards in the same pattern
- Is case-sensitive (matching Linux behavior)
- Supports complex patterns like
purity-?.*.*.ppkg
- ✓ Multiple wildcards in one pattern:
*test*.log - ✓ Mixed wildcards:
file?.tx* - ✓ Wildcards at any position:
*,test*,*test,*test* - ✓ Empty matches with
*:*matches everything including empty - ✓ Directory navigation with
.and.. - ✓ Relative and absolute paths
- Wildcard matching is case-sensitive (Linux standard behavior)
- The
?wildcard requires exactly one character (won't match zero characters) - Pattern
*.ppkgmatchesfile.ppkgand.ppkg(including hidden files starting with.) - Patterns are matched against filenames only, not full paths (except in specific commands)
# Pattern: file?.txt
file1.txt → matches (? = 1)
fileA.txt → matches (? = A)
file.txt → no match (? requires exactly 1 character)
file10.txt → no match (? matches only 1 character, not 10)
# Pattern: *.ppkg
test.ppkg → matches
.ppkg → matches (. at start is a character)
ppkg → no match (no . before ppkg)
# Pattern: *
everything → matches (including empty if listing directories)To test the wildcard support in the PureSimulator terminal:
ls /dev/sd* # Lists sda1, sdb1, etc.
ls /dev/sd?1 # Lists sda1, sdb1, sdc1 (but not sdab1)
ls /dev/s* # Lists all devices starting with 's'ls *.ppkg # Lists all .ppkg files
ls purity-?.*.*.ppkg # Lists purity-1.2.3.ppkg, purity-6.5.4.ppkg, etc.
ls file?.txt # Lists file1.txt, fileA.txt (but not file10.txt)
ls *test* # Lists all files containing 'test'cd /home/pureeng
ls . # Lists current directory
ls .. # Lists parent directory (/home)
cd .. # Changes to parent directory
cp ../file.txt . # Copies file from parent to currentmount /dev/sdb1 /mnt
cp /mnt/*.ppkg . # Copies all .ppkg files from /mnt to current directory
cp /mnt/purity-6.*.ppkg . # Copies specific version patterns
cp /mnt/file?.txt . # Copies files matching single-char patternls purity-[0-9].*.*.ppkg # Using wildcards for version matching
ls *config*.xml # Files containing 'config' with .xml extension
cp /mnt/*backup* . # Copy all files with 'backup' in the name# Type partial filename and double-tap Tab to autocomplete
ls puri<Tab><Tab> # Autocompletes to purity-*.ppkg files
cp /mnt/fil<Tab><Tab> # Autocompletes to file names starting with 'fil'cd /opt/Purity/bin
cd ../../etc # Go up two levels, then into etc
ls ../../../home # List files three levels up, then in home
pwd # Shows current directory after navigation# Mount the USB drive
mount /dev/sdb1 /mnt
# List available Purity versions
ls /mnt/purity-*.ppkg
# Install a specific version pattern
pureinstall /mnt/purity-6.5.*.ppkg
# Copy all installation packages for backup
cp /mnt/*.ppkg .# View all log files
ls /var/log/*.log
# View logs from current day
ls /var/log/*$(date +%Y%m%d)*.log
# Clean up old logs
rm /var/log/old_*.log# List all config files
ls /etc/*.conf
# Backup configuration files
cp /etc/*.conf /root/backup/
# Find specific config file
ls /etc/*network*.conf# Check all drive statuses
ls /dev/sd*
# View device information
cat /dev/sd?1
# List all mounted filesystems
df | grep /dev/sd*