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)
10
  • 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
    Commented Aug 12, 2013 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
    Commented Aug 12, 2013 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 {} \; Commented Aug 12, 2013 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. Commented Aug 12, 2013 at 12:18
  • 1
    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
    Commented Aug 12, 2013 at 12:19

1 Answer 1

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 \"{}\"" \;
1
  • 4
    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. Commented Aug 12, 2013 at 14:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .