Hi all,
Since I need to maintain the file name with time stamp as unique in unix, i need to write script.
Is there any way to capture the milli/micro seconds of unix system.
Please reply me. (2 Replies)
I have an archive file that holds a batch of statements. I would like to be able to extract a certain statement based on the unique customer # (ie. 123456). The end for each statement is noted by "ENDSTM".
I can find the line number for the beginning of the statement section with sed.
... (5 Replies)
I have a large directory of web pages. I am doing a search through the web pages using grep and would like to get a list of unique file names of search results. The following command works fine to give me a list of file names where term appears:
grep -l term *.html
However, since these are... (3 Replies)
Hi Unix Gurus,
In a script, I am trying to extract unique text from a set of filenames.
I have certain files like below in a directory:
OPEN_INV_01012011.xls
OPEN_INV_01022011.xls
OPEN_INV_01032011.xls
CLOSE_INV_01012011.xls
CLOSE_INV_01022011.xls
I need to extract just "OPEN_INV_" ... (4 Replies)
Is it possible to modify file like this.
1. Remove all the duplicate names in a define column i.e 4th col
2. Count the no.of unique names separated by ";" and print as a 5th col
thanx in advance!!
Q
input
c1 30 3 Eh2
c10 96 3 Frp
c41 396 3 Ua5;Lop;Kol;Kol
c62 2 30 Fmp;Fmp;Fmp
... (5 Replies)
I would like to print unique lines without sort or unique. Unfortunately the server I am working on does not have sort or unique. I have not been able to contact the administrator of the server to ask him to add it for several weeks. (7 Replies)
I'm attempting to write a script that will look into a directory, discover all unique names, create directories for their prefix names and place the files inside. I do this now one by one with a simple script but I'd like to automate the process.
The directory would contain something like: ... (6 Replies)
Hello Team,
I need your help on the following:
My input file a.txt is as below:
3330690|373846|108471
3330690|373846|108471
0640829|459725|100001
0640829|459725|100001
3330690|373847|108471
Here row 1 and row 2 of column 1 are identical but corresponding column 2 value are... (4 Replies)
Dear Users,
Appreciate your help if you could help me with splitting a large file > 1 million lines with sed or awk. below is the text in the file
input file.txt
scaffold1 928 929 C/T +
scaffold1 942 943 G/C +
scaffold1 959 960 C/T +... (6 Replies)
Discussion started by: kapr0001
6 Replies
LEARN ABOUT MOJAVE
mktemp
MKTEMP(1) BSD General Commands Manual MKTEMP(1)NAME
mktemp -- make temporary file name (unique)
SYNOPSIS
mktemp [-d] [-q] [-t prefix] [-u] template ...
mktemp [-d] [-q] [-u] -t prefix
DESCRIPTION
The mktemp utility takes each of the given file name templates and overwrites a portion of it to create a file name. This file name is
unique and suitable for use by the application. The template may be any file name with some number of 'Xs' appended to it, for example
/tmp/temp.XXXX. The trailing 'Xs' are replaced with the current process number and/or a unique letter combination. The number of unique
file names mktemp can return depends on the number of 'Xs' provided; six 'Xs' will result in mktemp selecting 1 of 56800235584 (62 ** 6) pos-
sible file names. On case-insensitive file systems, the effective number of unique names is significantly less; given six 'Xs', mktemp will
instead select 1 of 2176782336 (36 ** 6) possible unique file names.
If mktemp can successfully generate a unique file name, the file is created with mode 0600 (unless the -u flag is given) and the filename is
printed to standard output.
If the -t prefix option is given, mktemp will generate a template string based on the prefix and the _CS_DARWIN_USER_TEMP_DIR configuration
variable if available. Fallback locations if _CS_DARWIN_USER_TEMP_DIR is not available are TMPDIR and /tmp. Care should be taken to ensure
that it is appropriate to use an environment variable potentially supplied by the user.
If no arguments are passed or if only the -d flag is passed mktemp behaves as if -t tmp was supplied.
Any number of temporary files may be created in a single invocation, including one based on the internal template resulting from the -t flag.
The mktemp utility is provided to allow shell scripts to safely use temporary files. Traditionally, many shell scripts take the name of the
program with the pid as a suffix and use that as a temporary file name. This kind of naming scheme is predictable and the race condition it
creates is easy for an attacker to win. A safer, though still inferior, approach is to make a temporary directory using the same naming
scheme. While this does allow one to guarantee that a temporary file will not be subverted, it still allows a simple denial of service
attack. For these reasons it is suggested that mktemp be used instead.
OPTIONS
The available options are as follows:
-d Make a directory instead of a file.
-q Fail silently if an error occurs. This is useful if a script does not want error output to go to standard error.
-t prefix
Generate a template (using the supplied prefix and TMPDIR if set) to create a filename template.
-u Operate in ``unsafe'' mode. The temp file will be unlinked before mktemp exits. This is slightly better than mktemp(3) but still
introduces a race condition. Use of this option is not encouraged.
EXIT STATUS
The mktemp utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
The following sh(1) fragment illustrates a simple use of mktemp where the script should quit if it cannot get a safe temporary file.
tempfoo=`basename $0`
TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || exit 1
echo "program output" >> $TMPFILE
To allow the use of $TMPDIR:
tempfoo=`basename $0`
TMPFILE=`mktemp -t ${tempfoo}` || exit 1
echo "program output" >> $TMPFILE
In this case, we want the script to catch the error itself.
tempfoo=`basename $0`
TMPFILE=`mktemp -q /tmp/${tempfoo}.XXXXXX`
if [ $? -ne 0 ]; then
echo "$0: Can't create temp file, exiting..."
exit 1
fi
SEE ALSO mkdtemp(3), mkstemp(3), mktemp(3), confstr(3), environ(7)HISTORY
A mktemp utility appeared in OpenBSD 2.1. This implementation was written independently based on the OpenBSD man page, and first appeared in
FreeBSD 2.2.7. This man page is taken from OpenBSD.
BSD December 30, 2005 BSD