Re: Automatic way of applying the same command to a bunch of files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Smith wrote:
>>To use the {} replacement for the file, xargs should have the -i
>>option:
>>
>>    ... | xargs -0 -i sox '{}' ...
>>
>>Of course, the xargs manpage says that -i is deprecacted and you
>>should instead use -I replace-str.  You can make things more
>>readable this way as well:
>>
>>    ... | xargs -0 -I wav sox 'wav' ...
> 
> It does not work either:
>
> $ find . -name \*.wav -print0 | xargs -0 -I wav sox "{}" -r 44100 -t
> wav "output_{}"
> sox: Can't open input file '{}': No such file or directory

That's because you've used {} instead of wav.  The xargs -I option
specifies a replacement string to be used when running the command.
So if you say -I wav, then wav is the replacement string that is used.
The xargs -i option is shorthand for -I {}.

The important thing missing from the original xargs command was -i.
Without that, {} won't have any special significance.  I as just
pointing out that the xargs manpage labels -i as deprecated and
recommends the use of -I replace-str.

See the xargs manpage for details.

Of course, I wouldn't even bother with xargs in this case.  I'd do
just what Paul Howarth recommended in the beginning of this thread:

    for in in *.wav; do sox "$i" -r 44100 "output_$i"; done

- -- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
======================================================================
If a government were put in charge of the Sahara Desert, within five
years they'd have a shortage of sand.
    -- Dr. Milton Friedman

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iQFDBAEBAgAtBQJFEcJWJhhodHRwOi8vd3d3LnBvYm94LmNvbS9+dG16L3BncC90
bXouYXNjAAoJEEMlk4u+rwzjALoH/2i9Dd3c9Gu1oFa5hn4s2/xv/Ffim9i7oJyV
4VMmhUsCSeaqfHyM/4D4vZkgcmR6aOL3+WEObLQqfI18RHEvsLeoF/QPygURkmgg
0NdcqotsdM+zAX9dZ4jQMY/HiCzZyrlCuA9CN+qNlsKkLYIm2QRflKWqlms18hUA
bFvMWY73rxcSSFkwdZHnVaTS6uhftnaO7gXvA4+29FwpaKioJul1hFC5gmRv9wfU
hL/e17svWvFK1YCdySUl4JfxFG6Yy0DLWzNhK1lPEvVLwb3jO2D3g2MtTHVBQOsY
yi609ZBcjfGCuZSuNub9PZwzILvCW7UGVewowExyBvimBqXT0Kw=
=w6vo
-----END PGP SIGNATURE-----

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux