I have a names.txt
file with with the top line of text being
51 Pipe-line\Closed3\00001011_-_Portfolio\UW\Old\NID50_Future_022814.xlsx
I would like to write new filenames replacing \
with /
I wrote a script.sh
and invoked it using sh script.sh
.
My first attempt...
while read one two three; do
new=$(echo $two|tr '\\' '/')
echo $one
echo $two
echo $three
echo $new
done < ./names.txt
51
Pipe-lineClosed300001011_-_PortfolioUWOldNID50_Future_022814.xlsx
Pipe-lineClosed300001011_-_PortfolioUWOldNID50_Future_022814.xlsx
This ate the /
char. I found out passing a -r
will show the /
so my next attempt was
while read -r one two three; do
new=$(echo $two|tr '\\' '/')
echo $one
echo $two
echo $three
echo $new
done < ./names.txt
51
Pipe-line\Closed3
Pipe-line/Closed3
This eats half the filename. What is happening? How do I get this to work?
/
is handled much better there – lonewarrior556 Mar 29 '17 at 17:23