To empty the files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To empty the files
# 1  
Old 05-14-2010
To empty the files

Hi,

Using the shell script, how can I empty the files that are under a dir.

-Siva
# 2  
Old 05-14-2010
If you mean current dir with "under a dir":
Code:
for i in *; do >$i
done

# 3  
Old 05-14-2010
Thanks a lot..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Files exists with same name and not empty

Hi everyone, I am new to shell scripting.Please help. I have list of files under some path /opt/thomas/ FileNames : 1.txt,2.txt,3.txt I would like to check if these three files exists and not empty,continue with the script or else write error message file not found or file empty Thanks (2 Replies)
Discussion started by: thomas9192
2 Replies

2. Shell Programming and Scripting

> to empty files, but ambiguous redirect

Hi Everyone, # ll total 0 -rw-r--r-- 1 root root 0 2010-05-13 11:29 a1.log -rw-r--r-- 1 root root 0 2010-05-13 11:29 a2.log -rw-r--r-- 1 root root 0 2010-05-13 11:29 a3.log # rm a.log above rm no problem, but when i use "> a.log", it says "-bash: a.log: ambiguous redirect". ... (3 Replies)
Discussion started by: jimmy_y
3 Replies

3. Homework & Coursework Questions

Creating empty files

Use and complete the template provided. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a single command to create a new empty file in P1 called cloud9, I have to do it from my current working directory which is P3 cd ../ away P1... (1 Reply)
Discussion started by: dat350z
1 Replies

4. HP-UX

Critical files in /etc overwritten EMPTY!

The following files were wiped out - new empty files were left in their place. /etc/inittab, /etc/inetd.conf, and /etc/MANPATH The system is running HP-UX 11i v3 - Mar08. Anyone seen anything like this? Any ideas on a way to figure this out if it happens again or a suggested way to... (9 Replies)
Discussion started by: KEnglander
9 Replies

5. Shell Programming and Scripting

How to empty all files in a directory

Hi all, Can you tell me how to empty all files in a directory with a "find" command? It does not seem to work the way I try it: # ls -l *.dat -rw-r--r-- 1 root root 7 Jul 20 20:51 la2.dat -rw-r--r-- 1 root root 4 Jul 20 20:51 la.dat # find... (9 Replies)
Discussion started by: majormark
9 Replies

6. Shell Programming and Scripting

Empty Files

Hi, How can I check if a file is empty? I have read that I could done in this way: if then echo "non-zero length file" fi But nothing happens (3 Replies)
Discussion started by: DNAx86
3 Replies

7. Shell Programming and Scripting

deleting empty files in a directory

Hello Gurus, I want to delete only empty files (files with 0 bytes) at once from the local directory. Rightnow I need to go through all the files one by one manually and check the empty files before deleting them. Is there any unix command that finds and deletes empty files in a directory?... (5 Replies)
Discussion started by: berlin_germany
5 Replies

8. UNIX for Dummies Questions & Answers

How to find files not empty?

Is there any way, we can find files not empty? I know one can find empty files by using find with -size is equalled to 0. Please let me know, how I can find files greater than 0 or any other size in number? (2 Replies)
Discussion started by: videsh77
2 Replies

9. Shell Programming and Scripting

deleting the empty files

as of our requiremnt some x no of files will be created from a third party tool ,out of them one or two files will be empty i.e size is 0. so i want to remove those files which are empty. naming of the files which are created will be like this abc_.txt 0 size abc_1.txt 4000 size abc_2.txt... (1 Reply)
Discussion started by: srivsn
1 Replies

10. UNIX for Dummies Questions & Answers

move files from folder thats are not empty

Hi, I would like to write a shell script that moves files from one folder to another without retrieving the error 'can not find file or folder' when the folder is empty. Any ideas, Thx in advance, Steven. (8 Replies)
Discussion started by: Steven
8 Replies
Login or Register to Ask a Question