Re: automated editing of text files
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le 17/09/2011 00:40, Bob Proulx a écrit :
> Ah... Very good! An excellent suggestion! 'find' rocks! I will
> note three things here however.
>
> * One is that the find will recurse down through a possibly deep
> hierarchy of directories. It isn't an identical alternative for just
> looking for *.txt in the current directory. But probably that
> difference isn't important here. Or perhaps that difference will be a
> really desirable feature.
Use « -maxdepth 0 » to limit to the current level only
> * Secondly if the add-pre-nl.sh script handle multiple file arguments
> then instead of \; use + so that it calls it fewer times with as many
> file arguments as possible. It will be more efficient that way.
In this case, I prefere using « xargs » :
find -type f -name "*.txt" | xargs add-pre-nl.sh
And if there is space/single-quote/double-quote/new-line in some filenames :
find -type f -name "*.txt" -print0 | xargs -0 add-pre-nl.sh
> * And lastly that you forgot to include the directory path to find,
> probably a '.' wanted here.
No, « find » considers the current directory if no path is given =)
- --
Aeris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJOc9hXAAoJEK8zQvxDY4P9FJsH/2kfxAnqc10trIyJC7N6HW0I
x3Rff2Zg24+lhtRYRJPxPIXRebuFjCe1i3DVwPZ5lC9XSgX3HYPNdrxg+IDj40g/
0HsKlIEcRJen1szDGtLpyqyBHEa95kevpxd/rql9rcljJCjBCpkXnLdVLdXKjx68
QRr1a/sPAgiTK49JT+gFIdKjv9Q8ngDhMa2QhQ7Avw7wLbhd/pHrvQBi3VXteqI6
Tga6FYm9WN2DfSCD4aDPz9jdU9TSl9GGwNxm7wHqPmCDx7y8mzTD6hK/NPUo1eit
ZS9E0/OjokKlSl4WioC43kaQV/HKvebwABXKuny363KOmHazzLm/VfqxQzG8z7E=
=1UAu
-----END PGP SIGNATURE-----
Reply to: