generate unique filename in ksh on AIX

generate unique filename in ksh on AIX

Post by Prince Kum » Thu, 04 Nov 2004 03:09:25



I want to create many unique filename from my ksh program.

What would be the easiest way to accomplish this?

Should I just use something like TEMP_${RANDOM} or is there something
similar to mktemp or tmpnam in ksh?

Thanks,

 
 
 

generate unique filename in ksh on AIX

Post by Dana Fren » Sat, 06 Nov 2004 06:43:35



> I want to create many unique filename from my ksh program.

> What would be the easiest way to accomplish this?

> Should I just use something like TEMP_${RANDOM} or is there something
> similar to mktemp or tmpnam in ksh?

> Thanks,

http://www.mtxia.com/fancyIndex/Tools/Scripts/Korn/K93_Unix/mktemp_k9...

--
Dana French

 
 
 

generate unique filename in ksh on AIX

Post by rakesh shar » Sat, 06 Nov 2004 18:04:28



> I want to create many unique filename from my ksh program.

> What would be the easiest way to accomplish this?

> Should I just use something like TEMP_${RANDOM} or is there something
> similar to mktemp or tmpnam in ksh?

#!/bin/ksh -u
mkUniq() {
 set x `print /tmp/tmp.XXX.$RANDOM`
 shift
 while [[ -e $1 ]];do
  set x `print /tmp/tmp.XXX.$RANDOM`
  shift
 done
 print $1

Quote:}

# call it to get the unique filename
mkUniq
 
 
 

1. How to generate a unique filename



Check the functions tempnam() and tmpnam, these allow you to create
unique filenames.  Then just use those to open a file for temporary
access.  Also, there is a function tmpfile() which will return a
unique file descriptor.  (I think that this function is only availible
with ANSI C, though?)  Hope this helps some!

        - Dan C.

2. Help: NAT/DHCP devices

3. Getting a userid on server side, generating a unique number, etc.

4. SSH.. Port scan attack

5. generating relatively universal unique id

6. What can you do with a Solaris box?

7. Need to generate a 'unique' ID number?

8. Bad colors with Xpmac .. fine with MacOS

9. Name of the command to generate a unique (file) name?

10. How to get a unique filename?

11. ensuring unique FTP upload filenames

12. unique filenames in Makefile

13. automatically rename file to unique filename