What does the <<- redirection do in Bash here documents?

Study for the OSCP Linux Exam. Use our flashcards and multiple-choice questions to test your skills. Each query comes with detailed hints and explanations to enhance your preparedness. Get ready to conquer the exam!

Multiple Choice

What does the <<- redirection do in Bash here documents?

Explanation:
In Bash, the dash after the here-document delimiter lets you indent the block in your script and still have clean content processed. It does this by removing a leading tab character from each line of the here document before it's used. So you can align the block with the surrounding code using tabs, without those tabs appearing in the actual input. Important nuance: only leading tab characters are stripped. If a line starts with spaces instead of a tab, those spaces remain in the content. For example, using a block indented with tabs will yield output without those tabs, while indenting with spaces will not remove them. The dash variant isn’t about wildcard or other expansions—the behavior here is about stripping leading tabs for indentation convenience, not enabling or disabling expansions.

In Bash, the dash after the here-document delimiter lets you indent the block in your script and still have clean content processed. It does this by removing a leading tab character from each line of the here document before it's used. So you can align the block with the surrounding code using tabs, without those tabs appearing in the actual input.

Important nuance: only leading tab characters are stripped. If a line starts with spaces instead of a tab, those spaces remain in the content. For example, using a block indented with tabs will yield output without those tabs, while indenting with spaces will not remove them.

The dash variant isn’t about wildcard or other expansions—the behavior here is about stripping leading tabs for indentation convenience, not enabling or disabling expansions.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy