Sponsored Content
Full Discussion: && meaning in UNIX
Top Forums UNIX for Beginners Questions & Answers && meaning in UNIX Post 302966014 by Scrutinizer on Saturday 6th of February 2016 07:41:48 AM
Old 02-06-2016
Quote:
Originally Posted by Archana Batta
Hi,

I am not sure about awk but in Shell scripting the logical and operator should be "-a" but not "&&". Isn't it??

I tried below script using && which didn't work. But it worked only after replacing && with "-a".

Code:
if [ $a && $b ]
then
   echo "I am in IF block"
fi

Below syntax worked fine
Code:
if [ $a -a $b ]
then
   echo "I am in IF block"
fi

[..]
The -a operand is deprecated in the POSIX standard. The recommended way is to use the && operator like so (leaving the variable expansions unquoted, like in your example):
Code:
if [ $a ] && [ $b ]
then
   echo "I am in IF block"
fi

This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

what is the difference between Unix & linux, what are the advantages & disadvantages

ehe may i know what are the difference between Unix & Linux, and what are the advantages of having Unix as well as disadvantages of having Unix or if u dun mind i am dumb do pls tell me what are the advantages as well as the disadvantages of having linux as well. thanks (1 Reply)
Discussion started by: cybertechmkteo
1 Replies

2. UNIX for Dummies Questions & Answers

meaning of .& in shell

Hi , can anyone explain me the meaning of following line ". &13FNAME/version_encours/cfg/dfm.cfg" Regards (1 Reply)
Discussion started by: scorpio
1 Replies

3. Shell Programming and Scripting

meaning of & in sh shell

All, I have a line in my code like below , could any one please tell me what this actually mean what is the & doding there. I am in sh shell #!/bin/sh .............. mv &fname &III.tar.gz Thanks in Advance, Arun (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

4. Shell Programming and Scripting

Meaning of >&2

What does >&2 at the end of the statement echo "Alright man..." >&2 mean? (4 Replies)
Discussion started by: proactiveaditya
4 Replies

5. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

6. Shell Programming and Scripting

replace & with & xml file

Hello All I have a xml file with many sets of records like this <mytag>mydata</mytag> <tag2>data&</tag2> also same file can be like this <mytag>mydata</mytag> <tag2>data&</tag2> <tag3>data2&amp;data3</tag3> Now i can grep & and replace with &amp; for whole file but it will replace all... (4 Replies)
Discussion started by: lokaish23
4 Replies

7. Shell Programming and Scripting

Replace & sign to &amp word

Hi, I have text file abc.txt. In this file, I have the following data. Input: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith & Mrs Smith Mr Smith& Mrs Smith Mr Smith &Mrs Smith Output: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith &amp Mrs Smith Mr Smith&amp... (4 Replies)
Discussion started by: naveed
4 Replies

8. Shell Programming and Scripting

meaning of &1

All, In the below mentioned line --- $SCRIPT_FILES/wrapper_sleep.ksh > $MVXREFLOG 2>&1 what is the meaning of &1 here. Regards Oracle User (2 Replies)
Discussion started by: Oracle_User
2 Replies

9. Shell Programming and Scripting

How to write If statement using && and operator in Unix

Hi What is the syntax for if statement using && and || operator? if && ] || here its giving me an error to this if statement any suggestion?? (2 Replies)
Discussion started by: Avi
2 Replies

10. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies
pattern(3MENU)															    pattern(3MENU)

NAME
pattern - get and set a menu's pattern buffer SYNOPSIS
#include <menu.h> int set_menu_pattern(MENU *menu, const char *pattern); char *menu_pattern(const MENU *menu); DESCRIPTION
Every menu has an associated pattern match buffer. As input events that are printable characters come in, they are appended to this match buffer and tested for a match, as described in driver(3MENU). The function set_menu_pattern sets the pattern buffer for the given menu and tries to find the first matching item. If it succeeds, that item becomes current; if not, the current item does not change. The function menu_pattern returns the pattern buffer of the given menu. RETURN VALUE
The function menu_pattern returns a pointer, which is NULL if the menu parameter is NULL. Otherwise, it is a pointer to a string which is empty if no pattern has been set. It does not set errno. The function set_menu_pattern may return the following error codes: E_OK The routine succeeded. E_BAD_ARGUMENT Routine detected an incorrect or out-of-range argument. E_BAD_STATE Routine was called from an initialization or termination function. E_NOT_CONNECTED No items are connected to menu. E_NO_MATCH Character failed to match. E_SYSTEM_ERROR System error occurred (see errno). SEE ALSO
ncurses(3NCURSES), menu(3MENU). NOTES
The header file <menu.h> automatically includes the header file <curses.h>. PORTABILITY
These routines emulate the System V menu library. They were not supported on Version 7 or BSD versions. AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. pattern(3MENU)
All times are GMT -4. The time now is 04:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy