I am trying to find a meaning to this echo escape character:
echo -e "\b"
Can someone tell me or give me examples of the effect that this has when used. I know that \b is the backspace, but I cannot visualise it use like any other escape such as:
Like how carriage returns return the carriage, like how new lines cause a new line, back space moves the cursor back one space. It does not erase, just moves the cursor. This behavior happens wholly within the terminal, backspace is still just another character as far as any programs are concerned:
I want to fully understand how this lines of code do their job:
#!/bin/bash
SAVEIFS=IFS
IFS=$(echo -en "\n\b")
for f in $(cat mp3file.txt)
do
echo "$f"
done
IFS=$SAVEIFS
I can follow everything, but I cannot follow where IFS would find a backspace as field separator. For example, to loop over a number of song titles such as these ones:
$cat mp3file.txt
01 - Don't Eat the Yellow Snow.mp3
02 - Don't Drink the Rain.mp3
03 - What is Going On?.mp3
04 - Thank You, Thank You.mp3
05 - Back to Life, Back to Theback.mp3
These are not real song titles, but just a group of names I made for testing purposes. I don't see where it is possible that IFS would find the backspace as a field separator here. I guess that is why I find it more abstract than any other.
...badly, that's how. That's a useless use of cat and prone to truncating the list should it exceed the size of a shell variable, and even when it works it's wasteful since it reads the entire list into memory, and a bit of a hack since it uses IFS and argument lists to split lines instead of using the built-in read method. It can be done much better like this:
while read f
do
echo $f
done < mp3file.txt
As for why IFS had a backspace in it: I have no idea. The shell doesn't process backspaces specially, so maybe his data did have real, literal backspaces in it somehow, but that's not normal. It doesn't do anything for your files, since argument splitting (or read) will break on any character in IFS, not just all of them. It's not good example.