Sponsored Content
Top Forums UNIX for Dummies Questions & Answers if statements in shell to compare value Post 302573688 by vbe on Tuesday 15th of November 2011 09:06:53 AM
Old 11-15-2011
Code:
parameter1=""

if ( "$1" == "-l" ) ; then
    parameter1="-l"
else
    parameter1="-ltr"
fi

command="ls ${parameter1}"

echo $command


Last edited by vbe; 11-15-2011 at 10:23 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script cant recognize if else compare

hi I face the problem the if else statement dint return correct result for me my script as below: #!/bin/ksh sqlplus -s /nolog <<EOF connect databaseuser/password column num new_value num format 9999 set head off select count(*) num from table1; exit num EOF if ; then echo "$?"... (6 Replies)
Discussion started by: jaseloh
6 Replies

2. Shell Programming and Scripting

Running remote shell script containing sql statements

I have a shell script which resides on three SCO machines containing some simple sqlplus statments. I need to run these scripts remotely. Currently, I am trying to use rsh to do so: rsh hostname myscript args The problem is that the arguments to the sqlplus statements in the remote shell... (4 Replies)
Discussion started by: Madbreaks
4 Replies

3. UNIX for Advanced & Expert Users

how to compare text value in shell

Hi, I need to check that if user is not oracle the the script should exit out . But the below script always exits evenif I am logged as oracle. Plz help me........... USER=`id` echo $USER if ; then echo " You are logged as `id` , it must be oracle " exit 2 fi Regards (2 Replies)
Discussion started by: reply2soumya
2 Replies

4. UNIX and Linux Applications

How to compare two files using shell script

hi experts please help me to compare two files which are in different directory file1<file will be master file> (/home/rev/mas.txt} ex x1 x2 file2 <will be in different folder> (/home/rev/per/.....) ex x3 x4 the filesinside per folder i need to compare with master file... (1 Reply)
Discussion started by: revenna
1 Replies

5. Shell Programming and Scripting

Would like to know how to use the IF...THEN...ELSE statements in C shell

Hi I've only been using Unix for a few weeks but am really impressed with its capabilities and ease of use. I am, however, struggling with a shell script at the moment. I would like automated reports on Disk Usage and available free space. I've written a straight forward script that... (0 Replies)
Discussion started by: huskie69
0 Replies

6. Shell Programming and Scripting

Looping through a shell script with sql statements

Hello members, I'm working on the Solaris environment and the DB i'm using is Oracle 10g. Skeleton of what I'm attempting; Write a ksh script to perform the following. I have no idea how to include my sql query within a shell script and loop through the statements. Have therefore given a... (4 Replies)
Discussion started by: novice82
4 Replies

7. Shell Programming and Scripting

Can we use two shebang statements in a single shell script?

Hi, As per my understanding, we can use two shebang statements in a single shell script. Please see below snippet- #!/bin/bash .......## some code A #!/bin/csh .......## some code B exit 0; Here, code A will be executed using bash shell and code B will be executed with c shell. ... (9 Replies)
Discussion started by: tarunmudgal4u
9 Replies

8. Shell Programming and Scripting

Shell – File Compare

All, I have a set of files in the Source , e-g Afile.DAT Bfile.DAT Cfile.DAT .... AAfile.DAT ...etc I will know for sure the list of file name before I copy the same from the Source area Before I copy the files to Target , I need to make sure that I have received all the files... (5 Replies)
Discussion started by: Shanks
5 Replies

9. Programming

Shell script - if statements dont work

hi all, i have made a shell script and it runs until it reaches the if statement, doesn't the ! mean only if the command fails it will echo me that message and then exit can anyone please help me what is wrong with my code? many thanks, rob #!/bin/bash echo "is this archive... (10 Replies)
Discussion started by: robertkwild
10 Replies

10. Shell Programming and Scripting

Multiple expect/send statements not working in shell script

Hi I am trying the following in my bash script which logs into my machine and runs a command. Trying to solve this using expect. The first expect statement is hit and it enters the address "10.10.0.10" but when the second expect statement is hit it exits #!/bin/bash expect -c ' spawn... (2 Replies)
Discussion started by: skorada
2 Replies
pkgparam(1)							   User Commands						       pkgparam(1)

NAME
pkgparam - display package parameter values SYNOPSIS
pkgparam [-v] [-d device] [-R root_path] pkginst [param...] pkgparam -f filename [-v] [param...] DESCRIPTION
pkgparam displays the value associated with the parameter or parameters requested on the command line. The values are located in either the pkginfo(4) file for pkginst or from the specific file named with the -f option. One parameter value is shown per line. Only the value of a parameter is given unless the -v option is used. With this option, the output of the command is in this format: parameter1='value1' parameter2='value2' parameter3='value3' If no parameters are specified on the command line, values for all parameters associated with the package are shown. OPTIONS
Options and arguments for this command are: -d device Specify the device on which a pkginst is stored. It can be a directory pathname or the identifiers for tape, floppy disk, or removable disk (for example, /var/tmp, /dev/diskette, and /dev/dsk/c1d0s0). The special token spool may be used to rep- resent the default installation spool directory (/var/spool/pkg). -f filename Read filename for parameter values. -R root_path Defines the full path name of a subdirectory to use as the root_path. All files, including package system information files, are relocated to a directory tree starting in the specified root_path. -v Verbose mode. Display name of parameter and its value. OPERANDS
pkginst Defines a specific package instance for which parameter values should be displayed. param Defines a specific parameter whose value should be displayed. ERRORS
If parameter information is not available for the indicated package, the command exits with a non-zero status. EXIT STATUS
0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
pkgmk(1), pkgproto(1), pkgtrans(1), pkginfo(4), attributes(5) Application Packaging Developer's Guide NOTES
With the -f option, you can specify the file from which parameter values should be extracted. This file should be in the same format as a pkginfo(4) file. For example, such a file might be created during package development and used while testing software during this stage. SunOS 5.10 6 Nov 2000 pkgparam(1)
All times are GMT -4. The time now is 12:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy