use-gnu-coreutils
Original:🇺🇸 English
Translated
Enforces using GNU coreutils commands with 'g' prefix instead of Mac default BSD commands. Prohibits using Mac standard commands. MUST ALWAYS be applied when using coreutils commands like ls, find, sed, awk, grep, etc.
2installs
Added on
NPX Install
npx skill4agent add totto2727-dotfiles/agents use-gnu-coreutilsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Use GNU Coreutils with 'g' Prefix
Rule (CRITICAL)
ALWAYS use GNU coreutils commands with prefix instead of Mac default BSD commands.
gNEVER use Mac standard commands directly.
Command Mapping
| GNU Command (Use) | Mac BSD Command (Prohibited) | Description |
|---|---|---|
| | List directory contents |
| | Find files |
| | Stream editor |
| | Pattern scanning and processing |
| | Search patterns |
| | Concatenate files |
| | Copy files |
| | Move files |
| | Remove files |
| | Create directories |
| | Change file permissions |
| | Change file ownership |
| | Display/set date |
| | Change file timestamps |
| | Display first lines |
| | Display last lines |
| | Sort lines |
| | Remove duplicate lines |
| | Word count |
| | Cut fields |
| | Translate characters |
| | Build and execute commands |
| | Resolve absolute paths |
| | Display file status |
| | Read symbolic links |
| | Create links |
| | Shuffle lines |
| | Split files |
| | Base64 encode/decode |
| | MD5 checksum |
| | SHA256 checksum |
Examples
Good: Using GNU Commands
bash
# List files with GNU ls
gls -la
# Find files with GNU find
gfind . -name "*.ts" -type f
# Text processing with GNU sed
gsed -i 's/old/new/g' file.txt
# Pattern matching with GNU grep
ggrep -r "pattern" .
# Path operations with GNU realpath
grealpath --relative-to=/base /target
# File operations
gcp source.txt dest.txt
gmv old.txt new.txt
grm -rf directory/Bad: Using Mac BSD Commands
bash
# DO NOT USE Mac standard commands
ls -la
find . -name "*.ts"
sed -i '' 's/old/new/g' file.txt
grep -r "pattern" .
realpath file.txt
cp source.txt dest.txtCommon Patterns
File Operations
bash
# Copy with GNU cp
gcp -r source/ dest/
# Move with GNU mv
gmv file.txt newdir/
# Remove with GNU rm
grm -rf directory/Text Processing
bash
# Search and replace with GNU sed
gsed -i 's/pattern/replacement/g' file.txt
# Pattern matching with GNU grep
ggrep -E "pattern1|pattern2" file.txt
# Process with GNU awk
gawk '{print $1, $3}' file.txtFile Finding
bash
# Find files with GNU find
gfind . -type f -name "*.ts" -exec ggrep -l "pattern" {} \;
# Find and process
gfind . -name "*.log" -mtime +30 -deletePath Operations
bash
# Get absolute path
grealpath ./file.txt
# Get relative path
grealpath --relative-to=/base /targetInstallation Note
GNU coreutils can be installed via Homebrew:
bash
brew install coreutilsAfter installation, commands are available with prefix.
gRationale
- GNU coreutils provide consistent behavior across platforms
- Better compatibility with Linux systems
- More features and options than BSD versions
- Consistent behavior in scripts across different environments