Here-Documents and Here-Strings
Here-Documents and Here-Strings
Here-documents provide multi-line string input to commands:
# Expands variables
cat << EOF
User: $USER
Home: $HOME
EOF
# Quoted EOF: SUPPRESSES variable expansion (great for generating scripts/configs!)
cat << 'EOF' > /tmp/template.sh
#!/bin/bash
echo "Literal $VAR is not expanded during write"
EOF
# Here-Strings (<<<): Pass single strings to stdin without echo pipe
grep "root" <<< "$passwd_content"