Posts

Showing posts from February, 2014

How to empty the files in UNIX?

Image
There are two ways to empty the file are set of files at a time(using loops) in unix 1). Using the symbol  " > "   i.e. /local/home# > /bharath/file1  now the file1 became empty. Example: [root@www ~]# cat file1 this is my first file in linux linux is rhel6.4 linux kernel dvpd by linus torvalds [root@www ~]# ls -l file1 -rw-r--r--. 1 root root 84 Apr 22 05:19 file1 You have new mail in /var/spool/mail/root [root@www ~]# >file1 [root@www ~]# ls -l file1 -rw-r--r--. 1 root root 0 Apr 22 05:19 file1 [root@www ~]# cat file1 [root@www ~]# 2). using /dev/null we can empty the file as below. [root@www ~]# ls -l file2 -rw-r--r--. 1 root root 159 Apr 22 05:22 file2 [root@www ~]# cat file2 this is linux opensorce OS linux is very compatiblw Linux kernel is develped by linus torvalds liux os has 3 IPC's namely semaphore,sharedmemory,message queue [root@www ~]# cat /dev/null > file2 [root@www ~]# ls -l file2 -rw-r--r--. 1