I'm working on a quick script in bash where at the beginning, I set
IFS=$'\n'
. Right after I have a for loop:
for i in *;
do
j=${i//:/}
done
No matter what I do, a colon is never removed from $i
. I tried every method I could think of to remove characters from a string including sed
, tr
and more. I even tried using a backslash before the colon, or resetting IFS within the for loop.
The strange thing is that I can replace other characters, it's just the colon that's not working for me.
What should I do?
(Here's essentially the whole thing)
#!/bin/bash
IFS=$'\n'
for i in *;
do
one=${i//:/} ###no colons
two=${one::-4} ### remove file format
three=${two,,} ###make lowercase
four=${three// /-} ### replace spaces with dashes
five=${four//\'} ### remove any apostropes
six=${five//.} ### remove any periods
mkdir /home/"$whoami"/project/"$six"
done
IFS=$' \t\n'