Working with Shell Commands
Execute shell commands to interact with the system, files, and tools.
Best Practices
- Check before destructive operations: Use
ls,git status, etc. beforermorgit reset - Use absolute paths: Relative paths can break if working directory changes
- Proper quoting: Use single quotes for content with special characters
- Chain related commands: Use
&&to only continue if previous command succeeds
Common Patterns
Exploring the filesystem
# List files
ls -la
# Find files
find . -name "*.py" -type f
# Check directory structure
tree -L 2
Git operations
# Check status before committing
git status
# Stage specific files
git add path/to/file.py
# Never use git add . or git add -A
File operations
# Read files
cat README.md
# Search in files
grep -r "pattern" src/
# Copy with structure
cp -r src/ backup/
Avoiding Common Mistakes
- ❌ Don't use
rm -rfwithout careful review - ❌ Avoid
git commit -a- stage files explicitly - ✅ Use
pwdto verify current directory - ✅ Test commands on small data first