Yes, the test utility operator -nt stands for newer than. If you check the man page for the test utility on your system or look for the term "conditional expression" on the man page for your shell, you'll find lots of useful tests that can be performed in your shell scripts. (Note that "conditional expression" might be all lowercase, all uppercase, or have the first letter of each word capitalized depending on which shell's man page you're reading.)
Most of the operators that are available with the [[ command (if your shell has a [[ command) are also available with the test utility invoked with:
or with:
The test and [ utilities are available with all Bourne shell derived shells.
Hi,
I have the following question :
As far as I know unix doesn't store file creation dates.
Would that imply the following?
tar -cvzf backup.tar --newer
is equal to:
tar -cvzf backup.tar --newer-mtime ? (1 Reply)
Howdy folks.
I have a problem - I'm sure the answer is very simple, but I can't work it out.
I want to create a UNIX shell script that does what I've been doing in DOS batch files for years - that is, backing up files. By which I mean copying files from a source directory to a target... (4 Replies)
Dear All,
I'm new to unix scripting. I'm trying to write an utility script which has to check if one file is newer than another one. The condition is I dont know the full name of the first file. I searched google and this forum for any such examples, but couldn't find any or may be I would have... (9 Replies)
Hi,
I have a text file, foo.txt, it looks something like below. In the file there is a line that gives the date in the form of: Mon Jun 15 11:09:31 2008. I need to find which date is the newest and then store certain details of that list data to another file. So, in this sample text file, I... (6 Replies)
This should be a simple script, but can't find one with google search.
I just need to find the file that is in many directories, then overwrite that file with a newer version i.e.
find file.jar then overwrite with /root/file.jar
All I get in searches is substitute text with new test inside... (1 Reply)
Hello,
Can you please help me one this:
I have two servers: Server A and server B.
Every day on 03.00AM in only one on these two servers (randomly)is generated one file, lets say file.txt.
I want to copy this file also to the other server.
I want to create a perl script that does... (2 Replies)
Dear All,
I'm new to unix scripting. I'm trying to write an utility script which has to check if one file is newer than another one. $3 $4 $5 $6 are files .txt. Help me please.
for i in $3 $4 $5 $6
do
if
then
echo "$1 is newer than $i"
else
echo "$i is newer than $1"
fi (9 Replies)
Discussion started by: Manueldo
9 Replies
LEARN ABOUT HPUX
test
test(1) General Commands Manual test(1)NAME
test - condition evaluation command
SYNOPSIS
expr
DESCRIPTION
The command evaluates the expression expr and, if its value is True, returns a zero (true) exit status; otherwise, a nonzero (false) exit
status is returned. also returns a nonzero exit status if there are no arguments. The following primitives are used to construct expr:
True if file exists and is readable.
True if file exists and is writable.
True if file exists and is executable.
True if file exists and is a regular file.
True if file exists and is a directory.
True if file exists and is a character special file.
True if file exists and is a block special file.
True if file exists and is a named pipe (fifo).
True if file exists and its set-user-ID bit is set.
True if file exists and its set-group-ID bit is set.
True if file exists and its sticky bit is set.
True if file exists and has a size greater than zero.
True if file exists and is a symbolic link.
True if the open file whose file descriptor number is
fildes (1 by default) is associated with a terminal device.
True if the length of string
s1 is zero.
True if the length of the string
s1 is non-zero.
True if strings
s1 and s2 are identical.
True if strings
s1 and s2 are not identical.
s1 True if s1 is not the null string.
True if the integers
n1 and n2 are algebraically equal. Any of the comparisons and can be used in place of
These primaries can be combined with the following operators:
Unary negation operator.
Binary AND operator.
Binary OR operator
has higher precedence than
Parentheses for grouping.
Note that all the operators and flags are separate arguments to Note also that parentheses are significant to the shell and therefore must
be escaped. All file test operators return success if the argument is a symbolic link that points to a file of the file type being tested.
is interpreted directly by the shell, and therefore does not exist as a separate executable program.
EXTERNAL INFLUENCES
International Code Set Support
Single byte and multibyte character code sets are supported.
EXAMPLES
Exit if there are not two or three arguments:
Create a new file containing the text string if the file does not already exist:
Wait for myfile to become non-readable:
WARNINGS
When the form of this command is used, the matching must be the final argument, and both must be separate arguments from the arguments they
enclose (white space delimiters required.
Parentheses and other special shell metacharacters intended to be handled by test must be escaped or quoted when invoking from a shell.
Avoid such problems when comparing strings by inserting a non-operator character at the beginning of both operands:
This approach does not work with numeric comparisons or the unary operators because it would affect the operand being checked.
AUTHOR
was developed by the University of California, Berkeley and HP.
SEE ALSO find(1), sh-posix(1), sh(1).
STANDARDS CONFORMANCE test(1)