This discussion is archived
1 Reply Latest reply: Jan 3, 2013 8:32 AM by Dude! RSS

Numpty find command question

Bazza Newbie
Currently Being Moderated
I want to find a file and then zero it using cat /dev/null > filename.txt


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

gives me:

/tmp/test.trc 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
    Dude! Guru
    Currently Being Moderated
    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.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points