You've written a script that processes a list of files. You want to ensure that even if a filename contains spaces, it's treated as a single argument. Which built-in variable should you modify?

  • IFS (Internal Field Separator)
  • PS1 (Prompt String 1)
  • OIFS (Original Internal Field Separator)
  • FS (Field Separator)
To ensure that filenames with spaces are treated as single arguments in a script, you should modify the OIFS (Original Internal Field Separator) variable. This allows you to temporarily change the IFS value to a specific character (e.g., newline) and then restore it to its original value after processing the filenames. This ensures that spaces don't break the filenames into multiple arguments.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *