1

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

~/tmp >find mydor/ -name "*php"
mydor/es/c/packags.php
mydor/etns/inx.php
mydor/pacepors.php
mydor/XAE.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)
  • 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
  • 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
  • Probably I didn't reproduced the circumstances exactly, I had to specify the path to the executables, otherwise Windows' own find was executed. But as soon as I specified the path, it worked. – manatwork Aug 12 '13 at 12:19
0

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 \"{}\"" \;
  • 3
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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