Since I don't see this as resolved...I'm continuing this thread..
Moderator: Sorry, no - you get your own post. If anyone wants to see "this thread" click here.
Please let me know, how to solve the issue of extra comma on the end of the loop.
problem is
I have listed files in directory using ls *.txt|tr '\n' ','
to get abc.txt, def.txt,xyz.txt,
Each file name is passed as a parameter to the job.
After processing xyz.txt, loop tries to read the next value as there is comma after it and as there is none my sequence fails.
I also tried ls -m *.txt which gives me output as abc.txt, def.txt, xyz.txt which doesn't help in my case because my input to the
job will be /source/data/ abc.txt
As there is a space after data/ my command fails.
Ant insight would be great. Thanks.
Extra comma on the end of the loop
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
If you have an "extra" character at the end of a string, simply trim it. You can substring out one less than the length of the string or do the same with the Left() function. For the "ls -m" approach, I don't recall ever seeing it add an extra space in the delimited list, what UNIX are you running? ![Confused :?](./images/smilies/icon_confused.gif)
![Confused :?](./images/smilies/icon_confused.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers