Sponsored Content
Operating Systems HP-UX Difference between [condition] and [[condition]] and ((condition)) when used with if condition Post 302520133 by frank_rizzo on Friday 6th of May 2011 12:16:48 AM
Old 05-06-2011
inside [] or [[]] use -gt/-eq/-lt/etc... [[]] might be safe because it's built into the shell but you should use the proper operators.

inside (()) values will be treated as numeric. see also let


also - please use CODE tags around the logic.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help with if condition.

Hi, awk -F"#" '{if ($19~/^1A/) print $0}' Please explain how "~/^1A/" is working. Thanks in advance.....:) (1 Reply)
Discussion started by: tushar_tus
1 Replies

2. Shell Programming and Scripting

If condition

here is my script ######## #! /bin/sh export PATH=$PATH:/opt/mysql/bin/ #echo $PATH echo $LD_LIBRARY_PATH USER="root" PASS="xyz" DB="sme" DATE=$(date +%d%b%y_%k.%M.%S) #DATE=`date +%y-%d-%m` if mysqldump -u $USER -p$PASS $DB | gzip -9>/home/backup1/today_sme-$DATE.sql.gz then find... (10 Replies)
Discussion started by: kaushik02018
10 Replies

3. Shell Programming and Scripting

Use of condition with if...

hi all, I am writing a shell script in ksh.Scenerio is I am exporting a result set from teradata to a file and comparing its result with my assigend varaible.but this comaprison is not happening.I give my script here... set -x record=/tmp/error.txt count=/tmp/cnt.txt chmod 777 $count... (2 Replies)
Discussion started by: kapil chauhan
2 Replies

4. Shell Programming and Scripting

help with if condition

I do have a situation where , i need to zip the log files in the directory when the file exceeds more than 10MB. cd $ORACLE_HOME/network/log find . -type f -name "listener_*.log" > listeners Now i have all my *.log files listed in the listeners file So now i need to find the size of each... (5 Replies)
Discussion started by: naveen529
5 Replies

5. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

6. Shell Programming and Scripting

If condition

I am trying trying to find the percentage and compare it with a value. But even if the condition is not true the also it is taking the true value not the else value. x=`awk '{print $2}' out2.txt` y=`awk '{print $4}' out2.txt` z=$((100*$y/$x)) if ;then echo "high" else echo "low"... (2 Replies)
Discussion started by: arijitsaha
2 Replies

7. Shell Programming and Scripting

if condition

if chr1:109457160 1 109457160 99.1735537190083 + chr1:109457233 1 109457233 99.1735537190083 - chr1:109457614 1 109457614 99.1735537190083 + chr1:109457618 1 109457618 100 + chr1:109457943 1 109457943 100 - chr1:109458224 1 109458224 99.1735537190083 - file1.txt If 6th column in... (3 Replies)
Discussion started by: johnkim0806
3 Replies

8. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

9. Shell Programming and Scripting

Using if condition

Hello, I want to use if condition in an expression as below: $ORACLE_HOME is a variable something like below /oraprod04_01/app/oracle/product/10204 Now here it is product/10204 I want to check if $ORACLE_HOME has something which has a string like /product/10* then one statement should... (4 Replies)
Discussion started by: Vishal_dba
4 Replies

10. Shell Programming and Scripting

awk to update file with numerical difference if condition is met

In the file1 below if $9 and $12 are . (dot) then the value in $8 of file1 is used as a key (exact match) to lookup in each $2 of file2, when a match is found then the value of $4 in file1 is used to look for a range match within +/- 50 using the values in $4 and after in file2. The number of... (9 Replies)
Discussion started by: cmccabe
9 Replies
newgrp(1)						      General Commands Manual							 newgrp(1)

NAME
newgrp - Changes primary group identification of a shell process SYNOPSIS
newgrp [-l] [group] Obsolete Synopsis newgrp [-] [group] Note The C shell has a built-in version of the newgrp command. If you are using the C shell, and want to guarantee that you are using the com- mand described here, you must specify the full path /usr/bin/newgrp. See the csh(1) reference page for a description of the built-in com- mand. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: newgrp: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Changes the login environment to what would be expected if the user logged in again. Changes the login environment to what would be expected if the user logged in again. (Obsolescent) OPERANDS
A group name from the group database or a non-negative numeric group ID. Specifies the group ID to which the real and effective group IDs will be set. If group is a non-negative numeric string and exists in the group database as a group name, the numeric group ID associated with that group name will be used as the group ID. DESCRIPTION
The newgrp command changes the primary group identification of the current shell process to group. You remain logged in and the current directory is unchanged, but calculations of access permissions to files are performed with respect to the primary group ID. If you do not specify group, newgrp changes the group identification back to that specified for the current user in the /etc/passwd file. Only exported environment variables retain their values after you invoke newgrp. Otherwise, variables with a default value are reset to that default. If a password is required for the specified group, and you are not listed as a member of that group in the group database, you are prompted to enter the correct password for that group. If you are listed as a member of that group, no password is requested. If no password is required for the specified group, only users listed as members of that group can change to that group. [Tru64 UNIX] Only a user with superuser authority can change the primary group of the shell process to one to which that user does not belong. [Tru64 UNIX] When you invoke the newgrp command from a shell, the shell executes the command without forking a new process. Therefore, the shell you were using when you issued the newgrp command is unavailable after the newgrp command finishes. NOTES
[Tru64 UNIX] The newgrp command is also a built-in command for csh. There is no convenient way to enter a password into the group data- base. Use of group passwords is not encouraged because by their very nature they encourage poor security practices. EXIT STATUS
If newgrp succeeds in creating a new shell execution environment, whether or not the group identification was changed successfully, the exit status will be the exit status of the shell. Otherwise, a non-zero exit value is returned. The exit status of newgrp is generally inapplicable. ENVIRONMENT VARIABLES
The following environment variables affect the execution of newgrp: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization variables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the format and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. FILES
Group names declared on the system Password file SEE ALSO
Commands: csh(1), groups(1), id(1), login(1), Bourne shell sh(1b), POSIX shell sh(1p) Files: group(4), passwd(4) Standards: standards(5) newgrp(1)
All times are GMT -4. The time now is 07:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy