What is the simplest way to create a file of specific non-zero size just
from shell (using other programming languages, c for example, is not a
case). Filling character could be any.
Thanks
Eugene
Thanks
Eugene
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
will create a file `somefile' with `sometext' as its contents.
HTH
--
Joost Kremers
registered Linux user #230173
> > What is the simplest way to create a file of specific
> > non-zero size just from shell (using other programming
> > languages, c for example, is not a case). Filling
> > character could be any.
> man dd
> hth
> t
> --
> Oh! I've said too much. Smithers, use the amnesia ray.
[ please quote only the relevant portion of the article
you are following up, and then place your new text after
that ]
>> > What is the simplest way to create a file of specific
>> > non-zero size just from shell (using other
>> programming > languages, c for example, is not a
>> case). Filling > character could be any.
>> man dd
> dd requires an input stream (if=). what do I use for it?
dd if=/dev/zero of=FILENAME bs=1k count=64
Some *NIXen provide a mkfile(1).
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
BTW: could not find mkfile(1) in RH
Eugene
> [ please quote only the relevant portion of the article
> you are following up, and then place your new text after
> that ]
> >> On Thu, 18 Oct 2001 11:14:57 -0400,
> >> > What is the simplest way to create a file of specific
> >> > non-zero size just from shell (using other
> >> programming > languages, c for example, is not a
> >> case). Filling > character could be any.
> >> man dd
> > dd requires an input stream (if=). what do I use for it?
> /dev/zero, e.g. 64k file,
> dd if=/dev/zero of=FILENAME bs=1k count=64
> Some *NIXen provide a mkfile(1).
> hth
> t
> --
> Oh! I've said too much. Smithers, use the amnesia ray.
|>What is the simplest way to create a file of specific non-zero size just
|>from shell (using other programming languages, c for example, is not a
|>case). Filling character could be any.
it's very easy:
touch myfile.notfilled
and you have it...
Bye
Alexander
>|>What is the simplest way to create a file of specific non-zero size just
>|>from shell (using other programming languages, c for example, is not a
>|>case). Filling character could be any.
> it's very easy:
> touch myfile.notfilled
> and you have it...
--
Grant Edwards grante Yow! Am I in GRADUATE
at SCHOOL yet?
visi.com
> |>What is the simplest way to create a file of specific non-zero size just
> |>from shell (using other programming languages, c for example, is not a
> |>case). Filling character could be any.
> it's very easy:
> touch myfile.notfilled
> and you have it...
The question was about _non-zero_ size.
About the most reasonable answers would be thus, assuming
"zero-filled" is fine, and you want it 29 bytes long:
dd if=/dev/zero of=/my/new/blank/file bs=1 count=29
That'll create the file /my/new/blank/file, containing 29 ASCII
null's.
--
http://www.cbbrowne.com/info/lsf.html
There are few personal problems which can't be solved by the suitable
application of high explosives.
Modulo permissions issues of course.
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
> >> it's very easy: touch myfile.notfilled
> > Not quite. You answered the question "What is the
> > simplest way to create a file of specific _zero_ size?"
> Not necessarily. The file size will be zero if the file
> did not exist before. Otherwise it'll remain the same
> size as before the touch, but with updated (a|m)time.
> Modulo permissions issues of course.
If the file _did_ exist, then you haven't created a file; it _might_
be of non-zero size, but there are no guarantees. The question was
about _creating_ a file, so this doesn't respond to the question
anyways.
--
http://www.ntlug.org/~cbbrowne/advocacy.html
All generalizations are false, including this one.
>> >> it's very easy: touch myfile.notfilled
>> > Not quite. You answered the question "What is the
>> > simplest way to create a file of specific _zero_ size?"
>> Not necessarily. The file size will be zero if the file
>> did not exist before. Otherwise it'll remain the same
>> size as before the touch, but with updated (a|m)time.
>> Modulo permissions issues of course.
> Well, if the file did not exist, then you get a file of _zero_ size,
> which was not what was asked for.
> If the file _did_ exist, then you haven't created a file; it _might_
> be of non-zero size, but there are no guarantees. The question was
> about _creating_ a file, so this doesn't respond to the question
> anyways.
--
LinuxBear
___
{~._.~}
_( Y )_
(:_~*~_:)
(_)-(_)
-->>> On Thu, 18 Oct 2001 11:07:59 -0400,
-->
-->> What is the simplest way to create a file of specific
-->> non-zero size just from shell (using other programming
-->> languages, c for example, is not a case). Filling
-->> character could be any.
-->
-->man dd
-->
-->hth
-->t
Gotta have a script for every purpose, thought I can't say why this purpose
is proposed.....
##========script follows=================##
#!/bin/bash
## ? PEMS 2001 freely distributable/modifyable
## credit to be given to PEMS/ts
if [ -f newfile ]; then
rm newfile
fi
count=0;
varp=0;
if [ $1 ]; then
echo "argument found: $1";
while [ $count -lt $1 ]; do
if [ $varp -eq 48 ] && [ $count -lt $1 ]; then
printf "1\n" >> newfile;
varp=0;
((count+=2));
else
printf "a" >> newfile;
((varp+=1));
((count+=1));
fi
done
else
while [ $count -lt 2 ]; do
if [ $varp -eq 48 ]; then
echo "1" >> newfile;
varp=0;
((count+=1));
else
printf "a" >> newfile;
((varp+=1));
fi
done
fi
ls -lFa newfile
exit 0
##==usage: either <script-name> or <script-name number>==##
So, copy the script to a file, say, "makfileofsize".
Then set the executable bit: chmod 0744 makefileofsize
To run,
1. just enter "makefileofsize" to create a 100 byte file called newfile
2. enter "makefileofsize 400" to make a file of size 400 bytes, or any
other number for any other size given file size limits of system.
The file "newfile" will be the size as indicated above, but for every 50
bytes, noe will be a "line feed" character; this allows formatting the
data. You could easily modify the script to allow input of filenames as
command line arguments. I think the loops within loops make this script a
bit slow for sizes above about 5000bytes. Any scripting experts care to
improve its performance? *_- /ts
--
"If you can just get your mind together
Then come on across to me...." Jimi
Regards
Eugene
> -->>> On Thu, 18 Oct 2001 11:07:59 -0400,
> -->
> -->> What is the simplest way to create a file of specific
> -->> non-zero size just from shell (using other programming
> -->> languages, c for example, is not a case). Filling
> -->> character could be any.
> -->
> -->man dd
> -->
> -->hth
> -->t
> Gotta have a script for every purpose, thought I can't say why this
purpose
> is proposed.....
> ##========script follows=================##
> #!/bin/bash
> ## ? PEMS 2001 freely distributable/modifyable
> ## credit to be given to PEMS/ts
> if [ -f newfile ]; then
> rm newfile
> fi
> count=0;
> varp=0;
> if [ $1 ]; then
> echo "argument found: $1";
> while [ $count -lt $1 ]; do
> if [ $varp -eq 48 ] && [ $count -lt $1 ]; then
> printf "1\n" >> newfile;
> varp=0;
> ((count+=2));
> else
> printf "a" >> newfile;
> ((varp+=1));
> ((count+=1));
> fi
> done
> else
> while [ $count -lt 2 ]; do
> if [ $varp -eq 48 ]; then
> echo "1" >> newfile;
> varp=0;
> ((count+=1));
> else
> printf "a" >> newfile;
> ((varp+=1));
> fi
> done
> fi
> ls -lFa newfile
> exit 0
> ##==usage: either <script-name> or <script-name number>==##
> So, copy the script to a file, say, "makfileofsize".
> Then set the executable bit: chmod 0744 makefileofsize
> To run,
> 1. just enter "makefileofsize" to create a 100 byte file called newfile
> 2. enter "makefileofsize 400" to make a file of size 400 bytes, or any
> other number for any other size given file size limits of system.
> The file "newfile" will be the size as indicated above, but for every 50
> bytes, noe will be a "line feed" character; this allows formatting the
> data. You could easily modify the script to allow input of filenames as
> command line arguments. I think the loops within loops make this script a
> bit slow for sizes above about 5000bytes. Any scripting experts care to
> improve its performance? *_- /ts
> --
> "If you can just get your mind together
> Then come on across to me...." Jimi
1. cannot create file in mounted file system
Hello,
I have SunOS 5.5 in two Sparc-20 boxes. In box one I have done as root:
mkdir /x/y
'ls -ld /x/y' yields: drwxr-xr-x 2 root root <size/date> /x/y
share /x/y
'share' yields: - /x/y rw ""
In box two I have done as root:
mkdir /x/y
'ls -ld /x/y' yields: drwxr-sr-x 2 root sys <size/date> /x/y
mount host1:/x/y /x/y
'mount' yields: /x/y on host1:/x/y read/write/setuid/proto=udp/remote ..
cd /x/y
'touch z' yields: touch: a: Permission denied
How do I allow creating of file(s) in a mounted file system ?
--
Regards,
Marek Grinberg
|------------------------------------------------|
| web: http://www.msc.se |
|------------------------------------------------|
2. HP-UX Development Environment
3. file format for dbm created files
4. SVGALIB
5. mail to file : unable to create file
6. re-install
7. How to create files with a timestamp in the file name?
9. cannot unlink file or create files
10. created file permissions on group
12. How to get Users to create files with another group as owner??
13. Solaris 2.5 door interface - how to create .file???