tags:

views:

182

answers:

3

can someone help me with unix command to truncate the contents of the files in the directory. I am using Cygwin in windows.

+4  A: 

Just redirect from nowhere:

> somefile.txt
Ignacio Vazquez-Abrams
Thanks, wow, that works i am curious to know how/why ? redirection from nothing to the file makes content empty.
Anil Namde
A: 

If you want to truncate a file to keep the n last lines of a file, you can do something like (500 lines in this example)

mv file file.tmp && tail -n 500 file.tmp > file && rm file.tmp
David V.
+3  A: 
for file in *
do
  >$file
done
ghostdog74