Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create a null file?

Status
Not open for further replies.
Oct 22, 2001
215
US
Hi,
I am sure this is quite simple, but don't know what am I doing wrong....Hm...

I got a variable $in and I need to create empty file if it does not exist. The $in got three vales like (file1, file2 and file3).
I am creating file as such:
echo "">>$in
but when I try to write the file or do more it seemes it is not a valied file (?)
Can any one tell what is going on?
TIA
 
Hi:

to create a null file:

> $in

which is short-hand for:

cat /dev/null > $in

Regards,


Ed
 
That seemed did not work. This is what I tried:

for name in $in
touch ${file_out}
cat /dev/null > $in
done

but neither cat or touch is accepted. I tried without the loop, cat works but, it seems it is not valid file or probably not passing the varible.... Do I need a qoute?
Say if $n = file1
and file2 and so forth...

 
Hi:

Do you have a permissions problem? Do you have permission to write files in the working directory?

If you do have permissions to write in the directory, is your file creation mask, umask, set to something like 222 so while the file is created, you can't write to it?

Regards,


Ed
 
Thanks but no... there is no permission problem. However when I manuall create file1 and file2 and type 'ls' I can see them in a line like: file1 file2
but when the script creates it it is displaying vertical:
file1
file2

besides those above files are not readable! But I can read the null files that I create manually!
 
opps just tried the touch and it worked! strane but it did. The Cat did not!
 
be aware of what you're touch-ing [no pun inteded]:

for name in ${in}
do
touch ${name}
done;

vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top