Sponsored Content
Full Discussion: simple if command
Top Forums UNIX for Dummies Questions & Answers simple if command Post 302259552 by bn_unx on Tuesday 18th of November 2008 11:42:08 AM
Old 11-18-2008
simple if command

#! /bin/sh

envname=$1

if [ "${envname}" =""]; then
echo usage : `basename $0` envname
exit -1
fi

can someone explain what exactly this does
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need help with a simple command

You don't know the name of the command that could do a particular task. What command could you run to find the name of the command? (4 Replies)
Discussion started by: kurtbudd1
4 Replies

2. Shell Programming and Scripting

probably simple SED-command ...

Hello, I've got a problem with SED. It's my intention to shorten a file path (removing the file name) with the help of SED. Something like: tmp\folder1\folder2\blah.txt has to be transformed to tmp\folder1\folder2\. I suppose, it's on the tip of my tongue. Perhaps it's close to: sed... (2 Replies)
Discussion started by: sysadv
2 Replies

3. UNIX for Dummies Questions & Answers

Simple sed command

Hi, I have the following file: --# --#line1 --#line2 --#line3 --# --#line4 --#line5 and I want to use something like: sed 's/--#/newline/g' file > newfile to substitute the lines containing only '--#', but when I try, it replaces every instance of '--#' with 'newline' and I... (7 Replies)
Discussion started by: Dave724001
7 Replies

4. Shell Programming and Scripting

Help with a simple loop command!

Hi! I'm having problems to get this simple script done: I need to insert 50 lines with the value from the variable dtm=`date +"%d"` into a new file, how do I do that using the "for" or "while" loop commands ? Is there any other command I can use to do that ? I'm new to shell scripting, as you can... (8 Replies)
Discussion started by: dfs
8 Replies

5. Shell Programming and Scripting

Simple AWK command?

I am not that good with AWK. Is there a simple awk command I could use to get the word "this" from the following text besides using "awk -F ":" '{print $2} | awk -F " " '{print $1}"? :this is:that is: (6 Replies)
Discussion started by: 2dumb
6 Replies

6. Shell Programming and Scripting

alias a simple ls -l command

how do I alias the following command: ls -l |egrep 'drw|dr-|d--|d-w' The alias command needs single quotes and so does the above command, so this does not work: alias LSDIR 'ls -l |egrep 'drw|dr-|d--|d-w' ' My problem is how do I get a listing of only directories? Solaris 8 SUN Ultra 10... (4 Replies)
Discussion started by: ajp7701
4 Replies

7. Shell Programming and Scripting

awk command for simple join command but based on 2 columns

input1 a_a a/a 10 100 a1 a_a 20 200 b1 b_b 30 300 input2 a_a a/a xxx yyy a1 a1 lll ppp b1 b_b kkk ooo output a_a a/a 10 100 xxx yyy (2 Replies)
Discussion started by: ruby_sgp
2 Replies

8. Shell Programming and Scripting

Help with simple grep command

I am currently having a problem with displaying multiple occurences of a line using grep/sed combination. Let's say that I do grep "$anything" $file. When I do this it only displays a single line, but if I do grep -c "$anything" $file it says that there are 3 occurences of $anything, but how can... (15 Replies)
Discussion started by: puttster
15 Replies

9. Shell Programming and Scripting

please describe me some simple command

Hi everyone I'm new here and I don't know some command of unix, please help by describe me how it work, I study unix command by myself and can't search exactly means so...Thanks :D sqlplus -s /nolog @${SQLFILE} ${file_type} >> ${OUTPUT_FILE} date "+%Y%m%d%H%M%S" $/usr/bin/echo "INFO : $1"... (2 Replies)
Discussion started by: zound617
2 Replies

10. Shell Programming and Scripting

A simple awk command

Hi there, given the file FIELD1 FIELD2 FIELD3 FIELD4 FIELD5 FIELD6 FIELD7 FIELD8 FIELD9 FIELD10 FIELD11 Why does not awk '$6 == "FIELD6" {$6=="GREEN"}1' file do the work and replace"FIELD6" by "GREEN"? And second question, what is the purpose of the "1" at the end of... (5 Replies)
Discussion started by: la2015
5 Replies
SETENV(3P)						     POSIX Programmer's Manual							SETENV(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
setenv -- add or change environment variable SYNOPSIS
#include <stdlib.h> int setenv(const char *envname, const char *envval, int overwrite); DESCRIPTION
The setenv() function shall update or add a variable in the environment of the calling process. The envname argument points to a string containing the name of an environment variable to be added or altered. The environment variable shall be set to the value to which envval points. The function shall fail if envname points to a string which contains an '=' character. If the environment variable named by envname already exists and the value of overwrite is non-zero, the function shall return success and the environment shall be updated. If the envi- ronment variable named by envname already exists and the value of overwrite is zero, the function shall return success and the environment shall remain unchanged. The setenv() function shall update the list of pointers to which environ points. The strings described by envname and envval are copied by this function. The setenv() function need not be thread-safe. RETURN VALUE
Upon successful completion, zero shall be returned. Otherwise, -1 shall be returned, errno set to indicate the error, and the environment shall be unchanged. ERRORS
The setenv() function shall fail if: EINVAL The envname argument points to an empty string or points to a string containing an '=' character. ENOMEM Insufficient memory was available to add a variable or its value to the environment. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
See exec() for restrictions on changing the environment in multi-threaded applications. RATIONALE
Unanticipated results may occur if setenv() changes the external variable environ. In particular, if the optional envp argument to main() is present, it is not changed, and thus may point to an obsolete copy of the environment (as may any other copy of environ). However, other than the aforementioned restriction, the standard developers intended that the traditional method of walking through the environment by way of the environ pointer must be supported. It was decided that setenv() should be required by this version because it addresses a piece of missing functionality, and does not impose a significant burden on the implementor. There was considerable debate as to whether the System V putenv() function or the BSD setenv() function should be required as a mandatory function. The setenv() function was chosen because it permitted the implementation of the unsetenv() function to delete environmental vari- ables, without specifying an additional interface. The putenv() function is available as part of the XSI option. The standard developers considered requiring that setenv() indicate an error when a call to it would result in exceeding {ARG_MAX}. The requirement was rejected since the condition might be temporary, with the application eventually reducing the environment size. The ulti- mate success or failure depends on the size at the time of a call to exec, which returns an indication of this error condition. See also the RATIONALE section in getenv(). FUTURE DIRECTIONS
None. SEE ALSO
exec, getenv(), putenv(), unsetenv() The Base Definitions volume of POSIX.1-2008, <stdlib.h>, <sys_types.h>, <unistd.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Stan- dard is the referee document. The original Standard can be obtained online at http://www.unix.org/online.html . Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . IEEE
/The Open Group 2013 SETENV(3P)
All times are GMT -4. The time now is 11:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy