At the beginning of a bash shell script is the following line:
IFS=$'\n'
What is the meaning behind this collection of symbols?
At the beginning of a bash shell script is the following line:
What is the meaning behind this collection of symbols? |
|||||||||
|
Try this in a shell like bash (other shells may handle this differently, for example zsh):
The default value for
In other words, the shell thinks that whitespace is a word boundary. Now, try setting
Now, the shell splits The first character of
Compare to:
Note that in both examples, the shell will still treat all of the characters Another important thing to know is how so-called "IFS whitespace" is treated. Basically, as soon as For example, let's look at the string
Note how multiple, consecutive whitespace characters delimit two fields in the second example, while multiple, consecutive colons don't (since they are not whitespace characters). As for
|
|||||||||||||||||||||
|
Inside dollared single quotes, some characters are evaluated specially. For example, So, this particular line assigns newline to the variable IFS. IFS, in turn, is a special variable in bash: Internal Field Separator. As
|
|||
|
For short,
This syntax is not defined by POSIX, but was accepted for SUS issue 7. |
|||
|
Trick with
|
|||||
|
I prefered to explain
|
|||
|