The other day I was trying to loop some files that contained spaces. I was trying to delete the same string that appeared at the beginning of several files using substring removal.
Suppose the filename is "First - Second - file.txt" and I'd like to remove "First - Second - " so that only "file.txt" remains.
So I tried:
Code:
for i in First*; do mv $i ${i##* }; done.
But it didn't work and then someone told me that I needed to change the IFS. Which I did, following these instructions:
https://www.cyberciti.biz/tips/handl...s-in-bash.html
And it worked just fine.
The site suggests using IFS=$(echo -en "\n\b")
Could anyone explain to me exactly what is going on? How does bash process the loop and why does one need a backspace after a newline? I really don't understand the mechanism, even if it would seem rather basic.