Mailinglist Archive: opensuse (2772 mails)
| < Previous | Next > |
Re: [opensuse] Another Bash scripting question
- From: Randall R Schulz <rschulz@xxxxxxxxx>
- Date: Sat, 17 May 2008 07:00:51 -0700
- Message-id: <200805170700.51646.rschulz@xxxxxxxxx>
On Saturday 17 May 2008 06:33, Rodney Baker wrote:
The way you're using xargs is essentially a no-op here, since the output
is no different than if you skipped the xargs part.
However, if you put the action code into a separately executable script
file that takes multiple arguments and gave that command to xargs,
you'd have what you want.
So if your script was something like this:
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
#!/bin/bash --norc
for arg; do
# Do stuff with "$arg" (always quote it!)
done
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
Then just invoke it like this:
% for file in $(find * -print0 | xargs --null scriptName)
By the way, these braces are redundant.
Randall Schulz
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
Hi all.
I have a few directories containing wav files that have been ripped
from CDs and I'm trying to write a script to invoke sox to convert
them to mp3 format.
The filenames have whitespaces and hyphens in them e.g. 'artist - 01
- title with many words.wav'. I tried the following script but I'm
obviously doing something wrong...
#!/bin/bash
for file in `find * -print0 | xargs --null`
The way you're using xargs is essentially a no-op here, since the output
is no different than if you skipped the xargs part.
However, if you put the action code into a separately executable script
file that takes multiple arguments and gave that command to xargs,
you'd have what you want.
So if your script was something like this:
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
#!/bin/bash --norc
for arg; do
# Do stuff with "$arg" (always quote it!)
done
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
Then just invoke it like this:
% for file in $(find * -print0 | xargs --null scriptName)
do {
...
}
done
By the way, these braces are redundant.
...
I seem to be just going around in circles here. Any suggestions will
be greatly appreciated.
Thanks in advance,
Randall Schulz
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
| < Previous | Next > |