What if you could feed text to commands as easily as whispering a secret?
Why Here strings (<<<) in Bash Scripting? - Purpose & Use Cases
Imagine you want to quickly send a small piece of text to a command in your terminal, like searching for a word or counting characters. Without shortcuts, you might have to create a file or use complicated commands just to pass that tiny text.
Typing out extra commands or creating temporary files just wastes time and can cause mistakes. It feels like using a hammer to turn a screw--too much effort for something simple. This slows you down and clutters your workspace.
Here strings let you feed a short string directly into a command's input with a simple, clean syntax. It's like whispering the text straight to the command without any detours, making your scripts shorter and easier to read.
echo "hello" | grep hgrep h <<< "hello"It makes passing small text snippets to commands quick, neat, and error-free, speeding up your scripting and command-line work.
Suppose you want to check if a word exists in a short message without creating a file or typing multiple commands. Here strings let you do this instantly, like searching for 'error' in a log snippet you just typed.
Manual text input to commands can be slow and messy.
Here strings provide a simple way to send short text directly.
This makes scripts cleaner and faster to write.