I've been having the following issue:
I have a several paths (folders and files), that were done in either MAC or Windows system. Now in our server we want to automatize the access to them, and it should have been pretyt straight forward, but when we try this:
for subfolder in $(find $folder -mindepth 1 -maxdepth 3 -type d -name "A1*"); do
name=$(basename $subfolder)
echo $subfolder
What I got is something like this:
/home/datset/Data/A1
protease
from
Bytw
noth
(P456678888)
I've tried every sed, awk, whatever I could get my hand on that I thought it could work, but nothing has worked. I tried \r \n \^M.... Has anyone have an idea?
I guess your file name contains spaces (/home/datset/Data/A1 protease from Bytw noth (P456678888))?
The shell splits what is returned by your "find" at spaces.
find $folder -mindepth 1 -maxdepth 3 -type d -name "A1*" -print | while read subfolder; do
name=$(basename "$subfolder")
echo "$subfolder"
Note the quotes to ensure the integrity of the file names.