REGEX to separate paths by whitespace and do a loop

I am trying to do in a single line to take a list of paths separated by whitespace and then loop thru all the paths that were wrote but my regex is not working,

I have

echo {3} | sed 's/ //g' | while read EACHFILE
do
 .....

But for some reason is only taking always the first path that I have in the line as I mention it below

hpsvn mergebatch E1 Homepage uk/rwd/heroes/40034/hero.html uk/rwd/heroes/40035/hero.html

So with this regex it is only taking the first uk/rwd/heroes/40034/hero.html but never getting the 2nd or 3rd one. Any ideas?

I'm lost. The command echo {3} will send {3} as a single line to sed , the sed command (finding no spaces to remove) will send {3} to your while loop using read to set EACHFILE to {3} the first (and only) time through the loop. No pathnames (or filenames) have been passed to your loop in any way by this code???

  1. Is this a homework assignment?
  2. Where the names of the files you want to process are coming from?
  3. What operating system you're using?
  4. What shell you're using?
  5. Are you saying that the files you want to process have names that contain whitespace characters?

I am doing a custom svn merge function that will take the parameters the path of all the files that are wanted to be merged

hpsvn mergebatch E1 Homepage uk/rwd/heroes/40034/hero.html uk/rwd/heroes/40035/hero.html

so in the function, I am trying to do that my custom svn command will take a list of paths separated by space, then inside my function, in the while, I am separating by / to take the subdirectory and do the svn add and svn merge for each file. Currently my code is working but only for one path, but it is not taking the 2nd one.

Let me know if this was clear.

It is not clear.

In post #3, I asked 5 questions. I think you have now said that the answer to #5 is no.

Please answer the other 4 questions:

  1. Is this a homework assignment?
  2. What command, function, ... is used to create the list of pathnames you want to process?
  3. What operating system are you using?
  4. What shell are you using?

so we can make suggestions that might help you resolve your problem!

Is this a homework assignment? WORK ASSIGNMENT
What command, function, ... is used to create the list of pathnames you want to process? the paths are typed manually, pointing to the file that is in the webserver
What operating system are you using? shell, putty, unix
What shell are you using? putty

I'm still struggling with your request. Please give us a sample of "a list of paths separated by whitespace". If I presume such a list, your sed 's/ //g' will make it one single long string of no use in a for loop. And, "paths are typed manually, pointing to the file that is in the webserver" is beyond my imagination. Please give us samples of your input data and some rudimentary code snippet that is supposed to work on it.

And, "putty" is not a shell but a communication tool. Shells might be sth. like sh , ksh , bash , ( csh , tcsh )

If you're typing the paths in manually, just change:

echo {3} | sed 's/ //g' | while read EACHFILE
do
 .....

to:

printf '%s\n' hpsvn merge batch E1 Homepage uk/rwd/heroes/40034/hero.html uk/rwd/heroes/40035/hero.html | while read EACHFILE
do
 .....

or:

for EACHFILE in hpsvn mergebatch E1 Homepage uk/rwd/heroes/40034/hero.html uk/rwd/heroes/40035/hero.html
do
 .....

But, of course, all of this is assuming that you are using a shell that uses basic Bourne shell syntax. (As RudiC said, putty is not a shel. And shell, putty, unix is not an operating system.)

No needed to add the sed, I just removed and not it is taking the list of paths.

Thanks for the comments!