Sponsored Content
Top Forums Shell Programming and Scripting Rules with using double parentheses in Bash Post 302495220 by cfajohnson on Wednesday 9th of February 2011 04:52:06 PM
Old 02-09-2011
Quote:
Originally Posted by methyl
Some ideas:

Code:
#!/bin/bash
# scriptname : A script to do something with a directory
#
# Parameter validation
if [ ! $# -eq 1 ]


Code:
if [ $# -ne 1 ]

Quote:
Code:
then
       echo "Usage: scriptname directory"
       exit 1
fi
# Save supplied parameter
mydir="$1"


Code:
mydir=$1

Quote:
Code:
# Does the directory exist?
if [ ! -d "${mydir}" ]


Code:
if [ ! -d "$mydir" ]

Quote:
Code:
then
        echo "Directory $1 not found"
        exit 1
fi
# Processing continues here

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parentheses in perl find/replace

I'm trying to use the following command to do a batch find and replace in all commonly named files through a file hierarchy find . -name 'file' |xargs perl -pi -e 's/find/replace/g' which works fine except for a substitution involving parenthesis. As a specific example I'm trying to sub... (3 Replies)
Discussion started by: Jeffish
3 Replies

2. Shell Programming and Scripting

Replace text in parentheses

Hi I would like to replace a comma in parentheses to a semicolon for example. Other commas outside () stay unchanged. How can I do this? aaaa,bbb,ccc,ddd(eee,fff,ggg),hhh,iii to aaaa,bbb,ccc,ddd(eee;fff;ggg),hhh,iii Thanks (5 Replies)
Discussion started by: lalelle
5 Replies

3. UNIX for Dummies Questions & Answers

brackets vs parentheses - single and double

hi, unix gurus. i am wondering if someone can give me a clear explanation of the differneces between parentheses and brackets, both single and double. i have heard that double parentheses (( are used for numerical expressions and that single brackets [ are used for strings. but i see... (1 Reply)
Discussion started by: ankimo
1 Replies

4. UNIX for Dummies Questions & Answers

Brackets, parentheses in Shell Scripting

Hello, I have done a great deal of research on this and still cannot come to an understanding of the following: In if-else statements in shell scripting I have seen examples of single brackets, double brackets, single parantheses, and double paratheses. When should each one be used? And... (2 Replies)
Discussion started by: mojoman
2 Replies

5. Shell Programming and Scripting

How to insert Parentheses to each line in a file

Hi I have a file with numbers like this : 123 456 6798 9073233 12 8644 Now, I need to insert parentheses to each and every line like below : (123) (456) (6798) (9073233) (12) (8644) can anyone tell me a solution? (8 Replies)
Discussion started by: sudharsan23
8 Replies

6. UNIX for Dummies Questions & Answers

Replace all occurrences of strings with parentheses

Hi, I tried to adapt bartus's solution to my problem, without success. I want to replace all the occurences of this: with: , where something can contain an arbitrary number of balanced parens and brakets. Any ideas ? Best, (1 Reply)
Discussion started by: ff1969ff1969
1 Replies

7. Shell Programming and Scripting

When does an if statement need parentheses

I was looking at a script in my little book on bash and saw that one of the if statements had parentheses instead of brackets for the condition. I've been trying to find in my book where it talks about parentheses (because the examples on the if statement in an earlier chapter doesn't seem to... (3 Replies)
Discussion started by: Straitsfan
3 Replies

8. Shell Programming and Scripting

Help with extracting data within parentheses

This is my input file: a|b|c(ef)|g|h(km)|p My output file should look like: a|b|ef|g|km|p That is, pipe is the delimiter. The data within pipe must be displayed as it is but if it encounters any data within parentheses, then only the data within parentheses has to be displayed ( the data... (2 Replies)
Discussion started by: ksatish89
2 Replies

9. Shell Programming and Scripting

[All variants] remove first pair of parentheses

How to remove first pair of parentheses and content in them from the beginning of the line? Here's the list: (ok)-test (ok)-test-(ing) (some)-test-(ing)-test test-(ing) Desired result: test test-(ing) test-(ing)-test test-(ing) Here's what I already tried with GNU sed: sed -e... (6 Replies)
Discussion started by: useretail
6 Replies

10. Answers to Frequently Asked Questions

Add string to parentheses

Suppose I have this code : int main () { int i = NULL; /* incorrect */ return 0; } and I want to put the word between the two parentheses like this : int main (void) { int i = NULL; /* incorrect */ return 0; } which command is used to do it in Linux ? (2 Replies)
Discussion started by: steve120
2 Replies
GAMMA(3)						User Contributed Perl Documentation						  GAMMA(3)

NAME
PDL::GSLSF::GAMMA - PDL interface to GSL Special Functions DESCRIPTION
This is an interface to the Special Function package present in the GNU Scientific Library. SYNOPSIS
Functions FUNCTIONS
gsl_sf_lngamma Signature: (double x(); double [o]y(); double [o]s(); double [o]e()) Log[Gamma(x)], x not a negative integer Uses real Lanczos method. Determines the sign of Gamma[x] as well as Log[|Gamma[x]|] for x < 0. So Gamma[x] = sgn * Exp[result_lg]. gsl_sf_gamma Signature: (double x(); double [o]y(); double [o]e()) Gamma(x), x not a negative integer gsl_sf_gammastar Signature: (double x(); double [o]y(); double [o]e()) Regulated Gamma Function, x > 0 Gamma^*(x) = Gamma(x)/(Sqrt[2Pi] x^(x-1/2) exp(-x)) = (1 + 1/(12x) + ...), x->Inf gsl_sf_gammainv Signature: (double x(); double [o]y(); double [o]e()) 1/Gamma(x) gsl_sf_lngamma_complex Signature: (double zr(); double zi(); double [o]x(); double [o]y(); double [o]xe(); double [o]ye()) Log[Gamma(z)] for z complex, z not a negative integer. Calculates: lnr = log|Gamma(z)|, arg = arg(Gamma(z)) in (-Pi, Pi] gsl_sf_taylorcoeff Signature: (double x(); double [o]y(); double [o]e(); int n) x^n / n! gsl_sf_fact Signature: (x(); double [o]y(); double [o]e()) n! gsl_sf_doublefact Signature: (x(); double [o]y(); double [o]e()) n!! = n(n-2)(n-4) gsl_sf_lnfact Signature: (x(); double [o]y(); double [o]e()) ln n! gsl_sf_lndoublefact Signature: (x(); double [o]y(); double [o]e()) ln n!! gsl_sf_lnchoose Signature: (n(); m(); double [o]y(); double [o]e()) log(n choose m) gsl_sf_choose Signature: (n(); m(); double [o]y(); double [o]e()) n choose m gsl_sf_lnpoch Signature: (double x(); double [o]y(); double [o]s(); double [o]e(); double a) Logarithm of Pochammer (Apell) symbol, with sign information. result = log( |(a)_x| ), sgn = sgn( (a)_x ) where (a)_x := Gamma[a + x]/Gamma[a] gsl_sf_poch Signature: (double x(); double [o]y(); double [o]e(); double a) Pochammer (Apell) symbol (a)_x := Gamma[a + x]/Gamma[x] gsl_sf_pochrel Signature: (double x(); double [o]y(); double [o]e(); double a) Relative Pochammer (Apell) symbol ((a,x) - 1)/x where (a,x) = (a)_x := Gamma[a + x]/Gamma[a] gsl_sf_gamma_inc_Q Signature: (double x(); double [o]y(); double [o]e(); double a) Normalized Incomplete Gamma Function Q(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,x,Infinity} ] gsl_sf_gamma_inc_P Signature: (double x(); double [o]y(); double [o]e(); double a) Complementary Normalized Incomplete Gamma Function P(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,0,x} ] gsl_sf_lnbeta Signature: (double a(); double b(); double [o]y(); double [o]e()) Logarithm of Beta Function Log[B(a,b)] gsl_sf_beta Signature: (double a(); double b();double [o]y(); double [o]e()) Beta Function B(a,b) AUTHOR
This file copyright (C) 1999 Christian Pellegrin <chri@infis.univ.trieste.it> All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file. The GSL SF modules were written by G. Jungman. perl v5.8.0 2003-01-29 GAMMA(3)
All times are GMT -4. The time now is 09:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy