Re: long string using find and "-exec ls -ls" to find part-of fi

看板FB_questions作者時間11年前 (2014/07/01 05:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串11/20 (看更多)
On Sun, 29 Jun 2014 23:40:44 -0700, Gary Kline wrote: > ANYWAY, the thing learned tonight is that it's *XARGS* <cmd> > instead of -exec abcfubarCmd. Allow me to add one little reminder: When using xargs, usually _one_ program will be executed with a command line containing _all_ results of the find command. If you want to run a program on _each_ of the results, this is the typical sh solution: find ... | while read F; do somecommand $F done Or maybe less elegant: for F in `find ...`; do somecommand $F done But keep in mind things get more complicated when the file names contain valid, but "unpleasant" characters, such as spaces. In this case, reading this can help: David A. Wheeler: Filenames and Pathnames in Shell: How to do it Correctly http://www.dwheeler.com/essays/filenames-in-shell.html David A. Wheeler: Fixing Unix/Linux/POSIX Filenames: Control Characters (such as Newline), Leading Dashes, and Other Problems http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html But if you've been using "clean" file names, this shouldn't be a big problem. ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
文章代碼(AID): #1JiTTI-2 (FB_questions)
討論串 (同標題文章)
完整討論串 (本文為第 11 之 20 篇):
文章代碼(AID): #1JiTTI-2 (FB_questions)