0

I am trying to make a custom right click command for nautilus. I managed to find a useful content here.

What I don't understand is what does these two lines essentially mean ?

IFS_BAK=$IFS
IFS="
"

And these are present at the bottom too. What do they mean ?

Please help.

Sumit Jha
  • 2,095
  • 2
  • 21
  • 36

2 Answers2

2

IFS_BAK is essentially creating a backup of existing value of IFS variable.
The next line then assigns a new value to IFS i.e specific/required the script.
More info on Internal Field Separator (IFS) can be found here: https://unix.stackexchange.com/questions/16192/what-is-ifs-in-context-of-for-looping
https://unix.stackexchange.com/questions/184863/what-is-the-meaning-of-ifs-n-in-bash-scripting
https://unix.stackexchange.com/questions/26784/understanding-ifs

Community
  • 1
  • 1
riteshtch
  • 8,629
  • 4
  • 25
  • 38
0

Okay, I got it. It is called an 'Internal Field Separator', a special variable in shell.

If you set IFS to | (i.e. IFS=| ), | will be treated as delimiters between words/fields when splitting a line of input.

In the first line:

IFS_BAK=$IFS

the initial 'IFS' value is stored in the variable 'IFS_BAK' and the value of IFS is set to 'new line' by

IFS="
"

so that the entire line is treated as a 'single input'.

Later, at the end of the program, the IFS value is restored to what it was originally.

Sumit Jha
  • 2,095
  • 2
  • 21
  • 36