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(1B)					     SunOS/BSD Compatibility Package Commands						  test(1B)

NAME
test - condition evaluation command SYNOPSIS
/usr/ucb/test expression expression DESCRIPTION
test evaluates the expression expression and, if its value is true, sets 0 (true) exit status; otherwise, a non-zero (false) exit status is set. test also sets a non-zero exit status if there are no arguments. When permissions are tested, the effective user ID of the process is used. All operators, flags, and brackets (brackets used as shown in the second SYNOPSIS line) must be separate arguments to the test command; normally these items are separated by spaces. USAGE
Primitives The following primitives are used to construct expression: -r filename True if filename exists and is readable. -w filename True if filename exists and is writable. -x filename True if filename exists and is executable. -f filename True if filename exists and is a regular file. Alternatively, if /usr/bin/sh users specify /usr/ucb before /usr/bin in their PATH environment variable, then test will return true if filename exists and is (not-a-directory). This is also the default for /usr/bin/csh users. -d filename True if filename exists and is a directory. -c filename True if filename exists and is a character special file. -b filename True if filename exists and is a block special file. -p filename True if filename exists and is a named pipe (fifo). -u filename True if filename exists and its set-user- ID bit is set. -g filename True if filename exists and its set-group- ID bit is set. -k filename True if filename exists and its sticky bit is set. -s filename True if filename exists and has a size greater than zero. -t[ fildes ] True if the open file whose file descriptor number is fildes (1 by default) is associated with a terminal device. -z s1 True if the length of string s1 is zero. -n s1 True if the length of the string s1 is non-zero. s1 = s2 True if strings s1 and s2 are identical. s1 != s2 True if strings s1 and s2 are not identical. s1 True if s1 is not the null string. n1 -eq n2 True if the integers n1 and n2 are algebraically equal. Any of the comparisons -ne, -gt, -ge, -lt, and -le may be used in place of -eq. Operators These primaries may be combined with the following operators: ! Unary negation operator. -a Binary and operator. -o Binary or operator (-a has higher precedence than -o). (expression) Parentheses for grouping. Notice also that parentheses are meaningful to the shell and, therefore, must be quoted. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
find(1), sh(1), attributes(5) NOTES
The not-a-directory alternative to the -f option is a transition aid for BSD applications and may not be supported in future releases. If you test a file you own (the -r , -w , or -x tests), but the permission tested does not have the owner bit set, a non-zero (false) exit status will be returned even though the file may have the group or other bit set for that permission. The correct exit status will be set if you are super-user. The = and != operators have a higher precedence than the -r through -n operators, and = and != always expect arguments; therefore, = and != cannot be used with the -r through -n operators. If more than one argument follows the -r through -n operators, only the first argument is examined; the others are ignored, unless a -a or a -o is the second argument. SunOS 5.10 1 Apr 1996 test(1B)
All times are GMT -4. The time now is 12:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy