Sponsored Content
Top Forums UNIX for Dummies Questions & Answers extract a part of a path like (input: /etc/exp/home/bin ====> output: exp) Post 302268648 by yeclota on Tuesday 16th of December 2008 04:37:16 AM
Old 12-16-2008
Hi,
I have a solution with awk.

#!/bin/ksh

cd `dirname $0`/
APPLIHOME=`pwd | sed 's%/[^/]*$%%'`
echo "$APPLIHOME"

if [[ $# -lt 3 ]] then
echo
echo "ERROR : need 4 parameters "
echo "ERROR : Syntax error: [$shellprog.sh FILE DB PACKAGE ENV] "
exit 3
fi
echo "echo ${APPLIHOME} | awk -F '/' '{print \$3}'" > temp
PARAM=`ksh temp`
echo $PARAM

I add to your awk solution [\] to the print option ==>{print \$3} and it work.

Thanks for your help,
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

reg exp question

Hi, Should be a difference between ']]*' and ']+' ? I use them in bash with sed and grep. Thanks (1 Reply)
Discussion started by: ynir
1 Replies

2. Shell Programming and Scripting

reg exp for sed

$ cat file.txt asd <AA>dev <LL>def <RR>sha This works for me: $ sed -r 's/^ .*<LL>def/\t<LL>my/' file.txt asd <AA>dev <LL>my <RR>sha But, this does not work for me: $ sed -r 's/^\s+<LL>def/\t<LL>my/' file.txt asd ... (1 Reply)
Discussion started by: demoprog
1 Replies

3. Shell Programming and Scripting

Perl reg exp

Hi, I am using the following piece of code for extracting some data from in between some tags ... $text =~ /<TAG1>(.*)<\/TAG1>.*<TAG2>(.*)<\/TAG2>.*<TAG3>(.*)<\/TAG4>.*<TAG5>(.*)<\/TAG5>/; $tag1=$1; print "\n$tag1"; But I am getting an error like Use of uninitialized value in... (1 Reply)
Discussion started by: King Nothing
1 Replies

4. UNIX for Dummies Questions & Answers

exp command to extract particular rows

Hi, I'm new to unix so hopefully you can help! I'm using the below command to extract a tables contents and store it in a dmp file: exp OWNER/OWNER@LINK FILE=exp.dat TABLES=TABLE_TEST This works fine and dumps the table into the exp.dat file. What i can't figure out, is how to... (3 Replies)
Discussion started by: boijie
3 Replies

5. Shell Programming and Scripting

Regular exp in awk

Hi all, One small doubt, reg exp in awk, is it possible to extract the match of regular expression like in perl? eg: B R16288 Map3_NoCat B R16067 Map4_NoCat B R16647 Map3_NoCat B R16450 Map3_NoCat B R16106 Map6_NoCat B R16000 Map3_NoCat B R16395 Map3_NoCat B R16243 Map3_NoCat B R16023... (6 Replies)
Discussion started by: gvj
6 Replies

6. Shell Programming and Scripting

cp -p /home/* home/exp/*.date not working please help

:( ---------- Post updated at 01:51 AM ---------- Previous update was at 01:50 AM ---------- Not working ---------- Post updated at 02:04 AM ---------- Previous update was at 01:51 AM ---------- cp -p /home/* home/exp/*.`date` i am using this (4 Replies)
Discussion started by: rishiraaz
4 Replies

7. Shell Programming and Scripting

set output of linux cmd as a variable in .exp

I am trying to make a script to take commands from a .txt file ( line by line) and pass it using send ( used in another function ) what i am trying to achieve is : set nol "`grep '' ${exp_path2}/cmdlist.txt | wc -l `" as in shell script nol=`grep '' $exp_path2/cmdlist.txt | wc -l` ... (0 Replies)
Discussion started by: dixyantar
0 Replies

8. Emergency UNIX and Linux Support

Need Help On REG EXP in unix

Respected All, I have a very big xml in that i want to search only below 3 lines. <target name ="UpgradePrimaryBox" depends ="configureBox1"> <echo> Finished Upgrading Primary Box </echo> </target> grep -i "<target.*UpgradePrimaryBox" this gives me the first line. then i need to match... (7 Replies)
Discussion started by: ameyrk
7 Replies
POW(3)									 1								    POW(3)

pow - Exponential expression

SYNOPSIS
number pow (number $base, number $exp) DESCRIPTION
Returns $base raised to the power of $exp. Note In PHP 5.6 onwards, you may prefer to use the ** operator. PARAMETERS
o $base - The base to use o $exp - The exponent RETURN VALUES
$base raised to the power of $exp. If both arguments are non-negative integers and the result can be represented as an integer, the result will be returned with integer type, otherwise it will be returned as a float. EXAMPLES
Example #1 Some examples of pow(3) <?php var_dump(pow(2, 8)); // int(256) echo pow(-1, 20); // 1 echo pow(0, 0); // 1 echo pow(-1, 5.5); // PHP >4.0.6 NAN echo pow(-1, 5.5); // PHP <=4.0.6 1.#IND ?> NOTES
Note This function will convert all input to a number, even non-scalar values, which could lead to weird results. SEE ALSO
exp(3), sqrt(3), bcpow(3), gmp_pow(3). PHP Documentation Group POW(3)
All times are GMT -4. The time now is 08:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy