Interpretation of awk code in linux


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Interpretation of awk code in linux
# 1  
Old 11-24-2011
Interpretation of awk code in linux

HI
I have a following code:
Code:
CM_PROJHOME_DIR=`echo ${SCRNAME} | awk '{FS="/"; p=NF-5; for (i=1; i<= p ; i++) t=t$i"/"; print t}'`

where
Code:
SCRNAME=`whence $0 | sed -e 's/\.\///g'`

I need to modify the code to work in linux and also the interpretation like what is the code exactly doing.
What does the whence command do, i fired in linux it says command not found.

Thanks

Last edited by vee_789; 11-24-2011 at 05:59 AM..
# 2  
Old 11-24-2011
FS issue is the same as last time.

whence.
# 3  
Old 11-24-2011
I executed my script which contained this code
Code:
SCRNAME=`whence $0 | sed -e 's/\.\///g'`

And found that $0 is substitued by the script name i.e
whence cm_dsjobrun.sh and SCRNAME contains this value as SCRNAME=''
Due to which its giving me wrong result.
and after this the following code is executed
Code:
awk -F/ '{p=NF-5; for (i=1; i<= p ; i++) t=t$i"/" ; print t}'

Can you please explain me the following code and why a blank value is going in the variable SCRNAME. Please answer my full question.
# 4  
Old 11-24-2011
Read up on (g)awk, maybe?

Seriously, this is a fairly simple piece of code, and you have a lot of topics asking similar questions. There's no point in us doing your job for you.
# 5  
Old 11-24-2011
ok i will try it myself.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Interpretation of UNIX command

what does the below do. echo * | xargs ls | wc –l echo * - Output a string comprising the name of each file in the working directory, with each name separated by a space. xargs ls - construct argument list command wc -l - it will pipe the output to the wc command, which will... (4 Replies)
Discussion started by: houmingc
4 Replies

2. UNIX for Advanced & Expert Users

Interpretation of Ping behaviour

hi, working on Solaris 10. need your help on ping behaviour that I encountered. I ping from source to destination -bash-3.2# ping -s -t 128 10.10.10.200 PING 10.10.10.200: 56 data bytes <===== stops here for 2 minutues before getting reply back 64 bytes from 10.10.10.200:... (9 Replies)
Discussion started by: ghostdog74
9 Replies

3. AIX

lspath output interpretation

On my VIo I see the following for my disks: $ lspath | grep hdisk6 Enabled hdisk6 fscsi0 200600a0b82193f7,4000000000000 Enabled hdisk6 fscsi0 200700a0b82193f7,4000000000000 Enabled hdisk6 fscsi2 200600a0b82193f8,4000000000000 Failed hdisk6 fscsi2 200700a0b82193f8,4000000000000 $ lspath |... (8 Replies)
Discussion started by: petervg
8 Replies

4. Shell Programming and Scripting

Negating shell interpretation

I'm writing a Korn script but am having trouble because the shell interprets the asterisk in this case. Can anyone tell me if there is a way to fix this so that grep takes in STDIN without the interpretation? line="30 09 * * 1-4 /home/user01/bin/start" echo "$line" | grep 'start' (16 Replies)
Discussion started by: sprucio
16 Replies

5. Shell Programming and Scripting

Weird Interpretation by Awk

Hi, I am not sure what I am doing wrong but I am messing up some logic here. The input file is something like this: *___String Type A Here___String Type B Here___123 *___ ___String Type B Here___123 *___ ___String Type B Here___123 *___ ... (6 Replies)
Discussion started by: Legend986
6 Replies

6. IP Networking

DNS ENUM RR interpretation

Hi Guys, This is really really urgent. Am looking out for some quick answers. I'm developing a DNS Resolver client that interprets DNS Query repsonses & pass on the needful to DNS applications. When an ENUM query(modified to an nslookup naptr query) is issued & an NAPTR RR(Resource Record)... (1 Reply)
Discussion started by: smanu
1 Replies

7. AIX

interpretation of sar

hello with a sar i have this result: System configuration: lcpu=48 ent=4.00 14:06:37 %usr %sys %wio %idle physc %entc 14:06:39 26 9 3 62 1.63 40.7 14:06:41 26 9 3 63 1.58 39.4 14:06:43 ... (0 Replies)
Discussion started by: pascalbout
0 Replies

8. UNIX for Advanced & Expert Users

SAR -b interpretation

I have used SAR -b to get some Unix cache / buffer metrics and the results are confusing me a bit. The pread/s & pwrit/s are showing 0. However the lread/s and lwrit/s are showing figures. I note also that the bread/s and bwrit/s are showing figures. I believe that pread/s and pwrit/s is not... (3 Replies)
Discussion started by: jimthompson
3 Replies

9. UNIX for Dummies Questions & Answers

shell interpretation

I executed the following command in the korn shell: $ variable1="qwerty" ls | sort and the shell executed the 'ls | sort' command. I would have expected an error message from the shell, but instead of that the shell ran the 'ls | sort' command and didn't realize the variable assignement. ... (1 Reply)
Discussion started by: PhilippeCrokaer
1 Replies
Login or Register to Ask a Question