Results 1 to 6 of 6
I am in a test environment (of shell scripts - that's just something I had lying around) trying to clean out the contents of files. The overall reasoning behind this ...
- 11-28-2006 #1Just Joined!
- Join Date
- Jan 2006
- Posts
- 43
ambiguous redirect issues
I am in a test environment (of shell scripts - that's just something I had lying around) trying to clean out the contents of files. The overall reasoning behind this is:
If I have an abundant amount of log files that are taking up large amounts of space; I do not want to delete the log files, I would only want to delete the contents of the log files.
The command I ran was:
That gave me an error ... So then I tried:Code:cat /dev/null > ./*
Same error:Code:cat /dev/null > ./*.sh
bash: ./*.sh: ambiguous redirect
Anyone know why?
Thanks.
- 11-28-2006 #2
its ambiguous redirect coz you are not redirecting to single file.
casperIt is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 11-28-2006 #3Just Joined!
- Join Date
- Jan 2006
- Posts
- 43
How could i remove the contents of all the files then? Not the files themselves .. but the contents. .. Any ideas?
Originally Posted by devils_casper
- 11-28-2006 #4Just Joined!
- Join Date
- Jan 2006
- Posts
- 43
Alright - Figured it out.
I have a little BASH script (if you could call it that). It's actually just one line of code - but it works. To clear out a directory of log files, WITHOUT deleting the actual log file - meaning just clear the contents of each log file run this line of code (presuming you are in the directory that the log files are in (./* - could actually be "/var/log/"):
If the logs were in /var/log - run:Code:for i in ./*; do >$i
Code:for i in /var/log/*; do >$i
Thanks
- 11-28-2006 #5
ahaa ! i am glad you sorted out yourself......
i was going to post same 'loop' solution...
casperIt is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 07-12-2010 #6Just Joined!
- Join Date
- Jul 2010
- Posts
- 1
This would be quite faster to execute. It does break when you have too many files.
: | tee *



