Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

1
  • 1
    Good answer. Setting IFS is unnecessary, even if your files have spaces (I have tested this in Bash). In the general case (where, unlike here, you can't guarantee a substitution), it may be worth testing [ "x$file" = "x$newfile" ] || mv -- "$file" "$newfile" to avoid mv complaining about old and new being equal if neither substitution matches (I've also protected against files beginning with -, which we know won't happen in this specific case). Commented Apr 28, 2016 at 8:44