Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't get why echo prints empty line (latest cygwin version):

~/tmp >find mydor/ -name "*php"

~/tmp >find mydor/ -name "*php" -exec echo {} \;
~/tmp >find mydor/ -name "*php" -exec echo "{}" \;
~/tmp >find mydor/ -name "*php" -exec echo '{}' \;

~/tmp >

~/tmp >find --version
find (GNU findutils) 4.5.11
Packaged by Cygwin (4.5.11-1)
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)
share|improve this question
Works for me. You will have to give us details about find and echo, for example from which packages they come and what are their versions. – manatwork Aug 12 '13 at 12:07
Thank you, I've updated my question – Olivier Pons Aug 12 '13 at 12:09
Are you running it from the Cygwin terminal? (The installer puts an icon on your desktop, pointing to “C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -” or similar.) – manatwork Aug 12 '13 at 12:12
Running from tty with C:\cygwin\bin\mintty.exe and base path C:\cygwin\bin. More strange: this works: find mydor/ -name "*php" -exec cat {} \; – Olivier Pons Aug 12 '13 at 12:13
What echo command is find calling? What does bash -c 'type -a echo' tell you? The first non-builtin one would be the one it calls. – Stéphane Chazelas Aug 12 '13 at 12:18
up vote 0 down vote accepted

I did find the answer. Here's how I made it work (and there's a solution to exec 2 process in a row only if the first one succeded, which I didn't found with google):

find ./ -name "*php" -exec sh -c "sed 's/ \+ /\t/g' \"{}\" > tmpfile && mv tmpfile \"{}\"" \;
share|improve this answer
DO NOT embed the {} in the sh code! See sed -i (with GNU sed but you're already using a GNUism with \+) for in-place editing. – Stéphane Chazelas Aug 12 '13 at 14:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.