1 Reply Latest reply: Jan 3, 2013 10:32 AM by Dude! RSS

    Numpty find command question

      I want to find a file and then zero it using cat /dev/null > filename.txt


      find /tmp/ -name "*.trc" -exec echo {} \;

      gives me:


      Great...so if I then try:

      find /tmp/ -name "*.trc" -exec cat /dev/null > {} \;

      I just get a lovely file {} :-)

      I've tried escaping the '>' but then I just get the cat output.

      Must be a neat way of doing this?

      Edited by: Bazza on Jan 3, 2013 7:33 AM
        • 1. Re: Numpty find command question
          How about the following:

          # echo "test" > testfile
          # cat testfile
          # find ./ -name testfile -exec dd if=/dev/null of={} \;
          0+0 records in
          0+0 records out
          0 bytes (0 B) copied, 1.642e-05 s, 0.0 kB/s
          # cat testfile

          It may not explain the issue, which is probably find specific, but it might solve your task.