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
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???
Is this a homework assignment?
Where the names of the files you want to process are coming from?
What operating system you're using?
What shell you're using?
Are you saying that the files you want to process have names that contain whitespace characters?
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.
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.)