Sponsored Content
Top Forums Shell Programming and Scripting How to use shell var for pattern string at KSH Post 302351684 by radoulov on Wednesday 9th of September 2009 08:53:37 AM
Old 09-09-2009
Code:
ksh-M 93t 2008-11-04$ ./t.sh 

Test without variable
---------------------
aa  ab

Test with with variable (exp=a@(a|b))
----------------------
aa  ab
ksh-M 93t 2008-11-04$ cat t.sh 
#!/bin/ksh
# name t.sh
exp='a@(a|b)'
touch a{abc}
print -- "\nTest without variable"
print -- ---------------------
ls a@(a|b)
print -- "\nTest with with variable (exp=$exp)"
print -- ----------------------
eval ls $exp

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

2. Shell Programming and Scripting

${!var} does not work in ksh

Anyone knows why the following function does not work in ksh (it does in bash)? var() # Displays var value; case insensitive { _var="$1" if ; then echo ${!_var} else _var=$(echo "$_var" | tr 'a-z' 'A-Z') echo ${!_var} fi unset _var }$ var home ksh:... (4 Replies)
Discussion started by: victorbrca
4 Replies

3. Shell Programming and Scripting

ksh: what does var=$(command) mean?

hi, i can see in a script it contains var=$( myFile | grep -i err ) why has this person done it like this? why not just var=`myFile | grep -i err` thanks (9 Replies)
Discussion started by: JamesByars
9 Replies

4. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

5. Shell Programming and Scripting

Search for a pattern in a String file and count the occurance of each pattern

I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported Input file is a free flowing file without any format example of output ERR-00001=5 .... ERR-01010=10 ..... ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies

6. Shell Programming and Scripting

ksh - building a var

This works #!/bin/ksh FILE="file.txt" dosumtin () { date >> FILE } for i in {1..5} do dosumtin done cat $FILE But instead of building a file, I want to do the same with a var or an array. That is, to build one that saves all 5 of the subs execution responses in a var or an... (8 Replies)
Discussion started by: popeye
8 Replies

7. Shell Programming and Scripting

Shell Script (ksh) - SQLPlus query filter using a string variable

Using ksh, I am using SQLPlus to execute a query with a filter using a string variable. REPO_DB=DEV1 FOLDER_NM='U_nmalencia' FOLDER_CHECK=$(sqlplus -s /nolog <<EOF CONNECT user/pswd_select@${REPO_DB} set echo off heading off feedback off select subj_name from subject where... (5 Replies)
Discussion started by: nkm0brm
5 Replies

8. Shell Programming and Scripting

Csh , how to set var value into new var, in short string concatenation

i try to find way to make string concatenation in csh ( sorry this is what i have ) so i found out i can't do : set string_buff = "" foreach line("`cat $source_dir/$f`") $string_buff = string_buff $line end how can i do string concatenation? (1 Reply)
Discussion started by: umen
1 Replies

9. Shell Programming and Scripting

PHP - Regex for matching string containing pattern but without pattern itself

The sample file: dept1: user1,user2,user3 dept2: user4,user5,user6 dept3: user7,user8,user9 I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Discussion started by: urello
8 Replies

10. Shell Programming and Scripting

Unable to replace string in AIX ksh shell

My variable contains the following string I wish to replace \n with "space" so the expected output is: I understand that the /n is not a new linein this case. I'm on AIX using ksh shell. Below is all that I tried. echo $str | sed -e "s#\n# #g"; echo $str | sed -e "s#\n#' '#g";... (5 Replies)
Discussion started by: mohtashims
5 Replies
FREXP(3)						     Linux Programmer's Manual							  FREXP(3)

NAME
frexp, frexpf, frexpl - convert floating-point number to fractional and integral components SYNOPSIS
#include <math.h> double frexp(double x, int *exp); float frexpf(float x, int *exp); long double frexpl(long double x, int *exp); Link with -lm. Feature Test Macro Requirements for glibc (see feature_test_macros(7)): frexpf(), frexpl(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or cc -std=c99 DESCRIPTION
The frexp() function is used to split the number x into a normalized fraction and an exponent which is stored in exp. RETURN VALUE
The frexp() function returns the normalized fraction. If the argument x is not zero, the normalized fraction is x times a power of two, and its absolute value is always in the range 1/2 (inclusive) to 1 (exclusive), that is, [0.5,1). If x is zero, then the normalized fraction is zero and zero is stored in exp. If x is a NaN, a NaN is returned, and the value of *exp is unspecified. If x is positive infinity (negative infinity), positive infinity (negative infinity) is returned, and the value of *exp is unspecified. ERRORS
No errors occur. CONFORMING TO
C99, POSIX.1-2001. The variant returning double also conforms to SVr4, 4.3BSD, C89. EXAMPLE
The program below produces results such as the following: $ ./a.out 2560 frexp(2560, &e) = 0.625: 0.625 * 2^12 = 2560 $ ./a.out -4 frexp(-4, &e) = -0.5: -0.5 * 2^3 = -4 Program source #include <math.h> #include <float.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { double x, r; int exp; x = strtod(argv[1], NULL); r = frexp(x, &exp); printf("frexp(%g, &e) = %g: %g * %d^%d = %g ", x, r, r, FLT_RADIX, exp, x); exit(EXIT_SUCCESS); } /* main */ SEE ALSO
ldexp(3), modf(3) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. 2008-10-29 FREXP(3)
All times are GMT -4. The time now is 11:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy