praka
February 10, 2009, 1:55am
1
I need to remove the entire file contents in file using the shell script.
Actually the grap -v command will create one more file and it occupy the space also.
I need to remove the entire file contents without creating new file using the shell scripting.
Please help me.
scorpio
February 10, 2009, 2:02am
2
if u want to nullify the file use
:>filename
praka
February 10, 2009, 2:06am
3
Thanks for your information.
Can you please give complete script.
pludi
February 10, 2009, 2:19am
4
Either
$ :>file
or, a bit more brutal,
$ rm -f file && touch file
The second one, though, will cause quite some havoc if a process still has a filehandle open on it.
praka
February 10, 2009, 2:23am
5
whether this code $ :>file
will remove all contents from file and put into another file?
If yes then i need code to remove all the file contents without creating new file.
The other code is ok. remove the file and touch file.
pludi
February 10, 2009, 2:34am
6
':>file' tells the shell to redirect the output of the NOOP command (which is none) to "file", creating it if it doesn't exist, or truncating it if it exists.