Sponsored Content
Full Discussion: Shell test conditions
Top Forums Shell Programming and Scripting Shell test conditions Post 303037296 by RudiC on Monday 29th of July 2019 12:43:14 PM
Old 07-29-2019
No luck needed. Excerpt from man bash (Ubuntu linux 19.04):



Quote:
CONDITIONAL EXPRESSIONS
.
.
.
-a file
True if file exists.
-b file
True if file exists and is a block special file.
.
.
.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

test with two conditions (OR)

Hi there, I'm very surprised that I can't find this myself and I'm sorry to bother you with such a stupid question. I just want to write a test with one condition or another one. I want either the first argument to be equal to 'this' or the second argument to be equal to 'that'. ~$ cat test ((... (3 Replies)
Discussion started by: chebarbudo
3 Replies

2. Shell Programming and Scripting

shell test command

I have a shell script, what i want to do is to use the test command and test it, but to be honest with you i really don't know, can someone give me some advices and how to use it? I have looked on the internet and saw some commands and scripts but the thing is where to start.....to test... (6 Replies)
Discussion started by: foottuns
6 Replies

3. Shell Programming and Scripting

How to Use Multiple if Conditions in Shell script

if -o ] then echo "Expected valid value" The above multiple if condition is NOT working in my script. I am getting the error as '-a' not expected. Can anyone help with the syntax for this? (5 Replies)
Discussion started by: dinesh1985
5 Replies

4. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

5. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

6. UNIX for Dummies Questions & Answers

multiple if conditions and EOF in a shell script

I want to create an IF condition with multiple condition, in the statement below I want to add OR EOF, can any one please advise how to do. if } != $sample ] && ; then echo ..... fi code tags please (1 Reply)
Discussion started by: analyst
1 Replies

7. Shell Programming and Scripting

Shell script executing both the conditions.

I have written this script. This is used for creating a backup folder. #!/bin/sh #set -x . /home/.profile usage="Usage is $0" usage="$usage " # Use the getopt utility to set up the command line flags. set -- `/usr/bin/getopt b: $*` # Process individual command line arguments while ;... (1 Reply)
Discussion started by: arijitsaha
1 Replies

8. Shell Programming and Scripting

Linux Shell: how to check a string whether meets some conditions

Hi, guys. In Linux Shell script, how can I check a string whether meets some conditions. e.g.: If a string str must start with a underscore or a alphabet, and it must contains at least one lowercase, one uppercase, one numeric and one punctuation, and its length must be more than 8 characters... (2 Replies)
Discussion started by: franksunnn
2 Replies

9. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file based on certain conditions

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Discussion started by: Vivekit82
1 Replies

10. Shell Programming and Scripting

How to use SQL Hard Code Conditions in UNIX Shell Script?

Hi All, I am trying to place one SQL query in Shell Script with Where Condition as Status='1' But after running the the script it is returning error as SQL0206N "1" is not valid in the context where it is used. SQLSTATE=42703 The query is working fine in Data Base. Please suggest... (1 Reply)
Discussion started by: sumanmca2006
1 Replies
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)
All times are GMT -4. The time now is 01:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy