{"id":387,"date":"2011-02-09T18:52:36","date_gmt":"2011-02-09T18:52:36","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=387"},"modified":"2011-06-02T10:04:43","modified_gmt":"2011-06-02T10:04:43","slug":"using-find-command-to-process-file-names-with-spaces","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=387","title":{"rendered":"Using find command to process file names with spaces"},"content":{"rendered":"<h2><span style=\"font-weight: normal; font-size: 13px;\">To process the output of\u00a0<a href=\"http:\/\/www.cyberciti.biz\/tips\/tag\/find-command\">find<\/a> with a command, try as follows:<\/span><\/h2>\n<pre>find . -print0 | while read -d $'\\0' file\r\ndo\r\n  echo -v \"$file\"\r\ndone<\/pre>\n<p>Try to copy files to \/tmp with spaces in a filename using\u00a0<a href=\"http:\/\/www.cyberciti.biz\/faq\/tag\/find-command\/\">find command<\/a> and shell pipes:<\/p>\n<pre>find . -print0 | while read -d $'\\0' file; do cp -v \"$file\" \/tmp; done<\/pre>\n<p>Or<\/p>\n<pre>\r\nfind . | while read -r file\r\ndo\r\n  echo \"$file\"\r\ndone\r\nReads Man Page\r\n\r\nread\r\n\r\nRead a line from standard input\r\n\r\nSyntax\r\n      read [-ers] [-a <var>aname<\/var>] [-p <var>prompt<\/var>] [-t <var>timeout<\/var>]\r\n              [-n <var>nchars<\/var>] [-d <var>delim<\/var>] [<var>name<\/var>...]\r\n\r\nOptions\r\n\r\n  -a <em>aname<\/em>\r\n    The words are assigned to sequential indices of the array variable aname,\r\n    starting at 0. All elements are removed from aname before the assignment.\r\n    Other name arguments are ignored.\r\n\r\n  -d <em>delim<\/em>\r\n    The first character of delim is used to terminate the input line,\r\n    rather than newline.\r\n\r\n  -e\r\n    If the standard input is coming from a terminal, Readline is used\r\n    to obtain the line.\r\n\r\n  -n <em>nchars<\/em>\r\n    read returns after reading nchars characters rather\r\n    than waiting for a complete line of input.\r\n\r\n  -p <em>prompt<\/em>\r\n    Display prompt, without a trailing newline, before attempting\r\n    to read any input. The prompt is displayed only if input is coming from a\r\n    terminal.\r\n\r\n  -r\r\n    If this option is given, backslash does not act as an escape character.\r\n    The backslash is considered to be part of the line. In particular, a backslash-newline\r\n    pair may not be used as a line continuation. \r\n\r\n  -s\r\n    Silent mode. If input is coming from a terminal, characters are not echoed.\r\n\r\n  -t <em>timeout<\/em>\r\n    Cause read to time out and return failure if a complete line\r\n    of input is not read within timeout seconds. This option has no\r\n    effect if read is not reading input from the terminal or a pipe.\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To process the output of\u00a0find with a command, try as follows: find . -print0 | while read -d $&#8217;\\0&#8242; file do echo [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-387","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=387"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/387\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}