Sponsored Content
Top Forums Shell Programming and Scripting Help!! needed to get the desired output Post 302854495 by rocky2013 on Tuesday 17th of September 2013 02:37:26 PM
Old 09-17-2013
Help!! needed to get the desired output

Am in need of your help to get the desired output.
Code:
nameSECURITY.SERVICES.CONFIG:GETVALUEisPrefetchedNsAccessLast2013-09-13 10:50:13 MESTsAccessTotal1sRunningcHitLastnamePUBLIC.SERVER:INVOKEisPrefetchedNsAccessLast2013-09-17 15:02:05 MESTsAccessTotal713991sRunning1namePUBLIC.STRING:CONVERTTOSTRINGisPrefetchedNsAccessLast2013-09-17 03:01:54 MESTsAccessTotal961sRunningcHitLast

1) I have data which has more thand 10,000 lines with the above same pattern.
2) I was checking the value of parameter 'sRunning' which should be a numerical value ( i.e, greater than 0 )
3) Here in the above live data the parameter(sRunning) is 'cHitLast and in the second case it is 1
4) I need to print the above 4 + 1(including sRunning ) values whereever the sRunning has a value greater than 0 ( zero) example shown below
5) Need to ignore if the value of sRunning which is other than numerical.
For the above code the output should be as below


Code:
name                 isPrefetched   sAccessLast               sAccessTotal  sRunningPUBLIC.SERVER:INVOKE  N             2013-09-17 15:02:05 MEST       713991     1

This was code given by jotne and it worked for some part but latter am not able to get the desired output.

Code:
nawk ' !f{ff=$0; f=1} !x && NR%2 { if(!(f>1 && $0 ~ ff)){printf "%s\t" "\t", $0} if(f==1){f++;next}}  !(NR%2) { d=d" "$0 } $0 ~ ff {print "\n"d; x=1;d=""} END{print d} '

Thanks a lot for your support.

---------- Post updated at 01:37 PM ---------- Previous update was at 01:34 PM ----------

Correction in the previous data
-----------------------------
Code:
name
SECURITY.SERVICES.CONFIG:GETVALUE
isPrefetched
N
sAccessLast
2013-09-13 10:50:13 MEST
sAccessTotal
1
sRunning
cHitLast
name
PUBLIC.SERVER:INVOKE
isPrefetched
N
sAccessLast
2013-09-17 15:02:05 MEST
sAccessTotal
713991
sRunning
1
name
PUBLIC.STRING:CONVERTTOSTRING
isPrefetched
N
sAccessLast
2013-09-17 03:01:54 MEST
sAccessTotal
961
sRunning
cHitLast

-----------
1) I have data which has more thand 10,000 lines with the above same pattern.
2) I was checking the value of parameter 'sRunning' which should be a numerical value( greater than 1 )
3) Here in the above code the value of parameter(sRunning) is 'cHitLast and in the second case it 1
4) I need to print the above 4 + 1(including sRunning ) values whereever the sRunning has a value greater than 0 ( zero) example shown below
5) Need to ignore if the value of sRunning is other than numerical.
For the above code the output should be as below
Code:
name                           isPrefetched  sAccessLast                   sAccessTotal  sRunning
PUBLIC.SERVER:INVOKE    N              2013-09-17 15:02:05 MEST      713991        1

This was code given by jotne and it worked for some part but latter am not able to get the desired output.
Code:
nawk ' !f{ff=$0; f=1} !x && NR%2 { if(!(f>1 && $0 ~ ff)){printf "%s\t" "\t", $0} if(f==1){f++;next}}
  !(NR%2) { d=d" "$0 } $0 ~ ff {print "\n"d; x=1;d=""} END{print d} '

Your help is much appreciated.
Thanks in advance.

Last edited by Scott; 09-17-2013 at 03:44 PM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help me in getting the desired output

I wanted to put "|" this sign at starting and at end of every field but its not working with first field like Currently the out put is : abc | abc | abc | xyz | xyz | xyz | But I want the out put in this form: | abc | abc | abc | | xyz | xyz | xyz | plz help me. (2 Replies)
Discussion started by: akash
2 Replies

2. Shell Programming and Scripting

script not giving the desired output

Hi, I have a script in which an entry like this ..... FILENAME_B="PIC_${DATE}0732*.JPG" The script connects to an ATM and pull a pic file from it.The format for the file is like PIC_2008061400000001.JPG in the ATM. Means 1st 8 digit is the date(YYYYMMDD) field 2nd 8 digit means hrs... (2 Replies)
Discussion started by: Renjesh
2 Replies

3. Shell Programming and Scripting

how to get desired output after redirection

hi i am running script which contains the commmnds and i am redirecting the script output to a file. like ./script 1> result.txt 2>&1 the above redirection is not working for commands when run in background in a script. but the problem here result.txt containg output which is repeated.... (3 Replies)
Discussion started by: raji
3 Replies

4. Shell Programming and Scripting

SED - output not desired

echo '0x3f 0xfa ae 0xeA' | sed '/0x/ y/abcdef/ABCDEF/' output: 0x3F 0xFA AE 0xEA echo '0x3f 0xfa ae 0xeA' | sed -r '/0x{2}/ y/abcdefg/ABCDEFG/' output: 0x3F 0xFA AE 0xEA my expected output: 0x3F 0xFA ae 0xEA What I want to achieve is change all hexadecimals to UPPER case(only those... (6 Replies)
Discussion started by: kevintse
6 Replies

5. Shell Programming and Scripting

need to get the desired output

Below is the my cide which is working fine but I am not getting the output indesired format.there is some problem in alignment.Can someone help me to correct this? if ]; then summary=$( echo -e "Please review the log file of auto coloclean utility.\n"; echo -e... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

6. Shell Programming and Scripting

How to grep the desired output and output to a file?

currently I have process from a raw file to this stage ALTER TABLE "EXCEL_ADMIN"."TC_TXN_VOID" ADD CONSTRAINT "PK_TC_TXN_VOID" PRIMARY KEY ("TC_TXN_IID") ALTER TABLE "EXCEL_ADMIN"."TC_TXN_AMT" ADD CONSTRAINT "PK_TC_TXN_AMT" PRIMARY KEY ("TC_TXN_AMT_IID") ALTER TABLE... (10 Replies)
Discussion started by: jediwannabe
10 Replies

7. Shell Programming and Scripting

Needed shell script to append desired text to each line in a file

Hi, I had generated a report in my tool as followsoutput.txt 43.35 9 i needed the script to generate a new file like below i want to append the text to each of these lines of my filenewoutputfile.txt should be Total Amount : 43.35 Record Count:9 Regards, Vasa Saikumar. ... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

8. Shell Programming and Scripting

Output not coming as desired.

Hi guys. I have a file containing some hosts and their IPs. host host1 192.168.2.10 host host2 192.168.2.11 host host3 192.168.2.12 I am writing a script where I want to print these values in 1 line. My script looks like RUNTIME_NODE=`cat hosts.properties | grep host` for i in... (7 Replies)
Discussion started by: Junaid Subhani
7 Replies

9. Shell Programming and Scripting

Pgrep not showing desired output

I am searching for a process that should be up and running. Im using the following command ps -ef | grep elasticsearch to get elastic+ 1673 1 0 Jan29 ? 05:08:56 /bin/java -Xms4g -Xmx4g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC... (1 Reply)
Discussion started by: Junaid Subhani
1 Replies

10. UNIX for Beginners Questions & Answers

Grep -P does not capture the desired output

Hi, I'm trying to filter the following output to only display information about an alarm where the Status: corresponds to Set. -------------------------------------------------------- Description: hw_optics: RX POWER LANE-0 LOW ALARM Location: Optics0/0/0/21... (6 Replies)
Discussion started by: sand1234
6 Replies
All times are GMT -4. The time now is 04:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy