I am using a Bash shell on a Ubuntu 12.04 LTS server, and it seems that IFS=$'\n' is being treated as IFS='n'.
Script in use:
concat=$(echo -n "concat:" && find /home/jhvisser/bin/Streamripper_rips -name '*.aac' -mtime -1 -exec echo -n "{}|" \;)
echo $concat
IFS=$'\n'
for i in =$(echo "$concat" | sed -e 's/^concat://' -e 's/|$//' -e 's/|/\n/g');
do rm "$i"
done
Output of $(echo "$concat" | sed -e 's/^concat://' -e 's/|$//' -e 's/|/\n/g')
:
rm: cannot remove `=/home/jhvisser/bi': No such file or directory
rm: cannot remove `/Streamripper_rips/Safe A': No such file or directory
rm: cannot remove `d Sou': No such file or directory
rm: cannot remove `d - Capital Cities (1).aac\n/home/jhvisser/bi': No such file or directory
rm: cannot remove `/Streamripper_rips/U Got It Bad - Usher.aac\n/home/jhvisser/bi': No such file or directory
rm: cannot remove `/Streamripper_rips/Life Of The Party - PRTY H3RO.aac\n/home/jhvisser/bi': No such file or directory
rm: cannot remove `/Streamripper_rips/i': No such file or directory
rm: cannot remove `complete/True Love - Pi': No such file or directory
rm: cannot remove `k.aac\n/home/jhvisser/bi': No such file or directory
rm: cannot remove `/Streamripper_rips/i': No such file or directory
rm: cannot remove `complete/The Other Side - Jaso': No such file or directory
rm: cannot remove ` Derulo.aac\n/home/jhvisser/bi': No such file or directory
rm: cannot remove `/Streamripper_rips/Karma - Kristi': No such file or directory
rm: cannot remove `a Maria.aac': No such file or directory
It is breaking at every 'n'. Check below to see the correct names of all the files:
/home/jhvisser/bin/Streamripper_rips/Safe And Sound - Capital Cities (1).aac
/home/jhvisser/bin/Streamripper_rips/U Got It Bad - Usher.aac
/home/jhvisser/bin/Streamripper_rips/Life Of The Party - PRTY H3RO.aac
/home/jhvisser/bin/Streamripper_rips/incomplete/True Love - Pink.aac
/home/jhvisser/bin/Streamripper_rips/incomplete/The Other Side - Jason Derulo.aac
/home/jhvisser/bin/Streamripper_rips/Karma - Kristina Maria.aac
I'm wondering why this may be happening? Shouldn't it be breaking at every newline?
For more detail of what is being done check out this chat.
-e $'s/|/\n/g'
sh
is notbash
. If you need a bash-specific feature like ANSI-C quoting, you have to specifically launch your script withbash
$(echo $concat)
-block with a=
-- does that serve any purpose?