1, determine whether the file exists, does not exist to create a file[Java]View Plaincopyprint?
File file=new file ("c:\\users\\qping\\desktop\\javascript\\2.htm");
if (!file.exists ())
{
try {
File.createnewfile ();
} catch
Test Condition Expression Description
File symbols:
[Root@lamp test]# Help testtest:test [expr]Evaluate conditional expression.Exits with a status of 0 (True) or 1 (false) depending onThe evaluation of EXPR. Expressions May is unary or binary.
Conditional expression ("CONDITIONAL EXPRESSIONS")
Conditional expressions are used in [composite commands and built-in command test and [to test file properties for string and arithmetic comparisons.] An expression is constructed using the
$ () and "(anti-quote ) are used to do command substitution. Next, let's see ${} ... It's actually used for variable substitution. Shell if interpretation statements are common:[Front and rear spaces] Front Space[-D file] True if file exists and
Objective:No matter what programming language is inseparable from conditional judgment. The shell is no exception.Copy CodeThe code is as follows:If List ThenDo something hereElif List ThenDo another thing hereElseDo something else hereFiEX1:Copy
Writing the first shell scriptLike other languages, we use any kind of text editor, such as Nedit, Kedit, emacs, vi, etc. to write our shell program. The program must start with the following line (must be in the first line of the file):#!/bin/shThe
1. string Judgments
STR1 = str2
True when two strings have the same content, length
Str1! = str2
True when strings str1 and str2 are unequal
-N str1
True when the length of a string is
Xi. functionsThe shell function is defined by the description of the shell grammar above and holds a series of commands waiting to be executed later. When the shell function name is used as a simple command name, a series of commands associated with
[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if file exists and is a directory.[-E File] True if file exists.[-F file] True if file
[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if file exists and is a directory.[-E File] True if file exists.[-F file] True if file
[ -a file] is true if file exists. [ -b file] True if file exists and is a block special file. [ -c file] True if file exists and is a word special. [ -d file] True if file exists and is a directory. [ -e file] is true if file exists. [ -f file]
Recently scripting, I often see conditional statements with the IF [-X $variable] class, not knowing what the meaning of the corresponding parameter is,The excerpt is as follows: from http://blog.csdn.net/aaaaatiger/article/details/1713611thanks!1[ -
[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if file exists and is a directory.[-E File] True if file exists.[-F file] True if file
If statement format:If condition then statements [elif condition then statements ...] [Else statements] fiThe syntax for the most streamlined if command is:if TEST-COMMANDS; then CONSEQUENT-COMMANDS; fiThe IF condition judgment statement
This article mainly introduced the shell script if condition judgment and the judgment condition summary, this article first gave the IF condition judgment the grammar, then gave the commonly used judgment condition summary, needs Friend can refer
The shell condition determines if the-Z to-D meaningShellfilestringless Terminal user[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if
From: http://m.jb51.net/article/56553.htm This article mainly introduced the shell script if condition judgment and the judgment condition summary, this article first gave the IF condition judgment the grammar, then gave the commonly used judgment
[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if file exists and is a directory.[-E File] True if file exists.[-F file] True if file
by Francis_hao Oct 1,2017This article extracts the Man Handbook from bashConditional expressionsThe conditional expression is composed of a composite command [[or] built-in command test and [used for testing file properties and string or numeric
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.