Need Help with greping two line from a file Pls help ASAP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Help with greping two line from a file Pls help ASAP
# 1  
Old 05-26-2011
Need Help with greping two line from a file Pls help ASAP

Hi all - I''m in a little bit of jam - If you can please help

I have a file that has the following content ( please see below)


I need to read the file and then get this result in this format

------------- To put out in this format
Code:
name: sophis   Total: 22328
name: tca       Total: 23
Name :  kpatel  Total: 0

----------- The file content is as follow
Code:
                    name: sophis
                channels: 2
                   total: 22328
      aggregateItemLimit: 100000
        maxPriorityClass: 1
                    name: tca
                channels: 1
                   total: 23
      aggregateItemLimit: 100000
        maxPriorityClass: 1
                    name: kpatel
                channels: 2
                   total: 0
      aggregateItemLimit: 100000
        maxPriorityClass: 1
                    name: ts
                channels: 1
                   total: 0
      aggregateItemLimit: 100000
        maxPriorityClass: 1
                    name: etfservice
                channels: 1
                   total: 2884
      aggregateItemLimit: 100000
        maxPriorityClass: 1


Last edited by Scott; 05-26-2011 at 06:38 PM.. Reason: Code tags
# 2  
Old 05-26-2011
Code:
 awk '/name/{n=$2}/total/{print "Name: " n " Total: "$2}' input

should work
This User Gave Thanks to mirni For This Post:
# 3  
Old 05-26-2011
thanks a whole bunch !!!! that works beautifully
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Partial content greping into a 3rd file

Hi, I do have couple of files in folder. The names of each of the files have a pattern. B_A17_A17_1T.txt B_A17_A17_2T.txt B_A17_A17_3T.txt B_A17_A17_7T.txt ..... ..... B_A17_A17_45T.txt Each of the above files have the same pattern of data with 4 columns and have an header for... (10 Replies)
Discussion started by: Kanja
10 Replies

2. Shell Programming and Scripting

Greping values from a text file

Hi All, I have 100's of files in the following format. I need to grep or parse out some values from each of the files {  “tree”: “((A:0.2{0},B:0.09{1}):0.7{2},C:0.5{3}){​4};”,  “placements”:  , ], “n”: },   {“p”: ], “n”: } ],  “metadata”:  {“invocation”:   “pplacer -c... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

3. Shell Programming and Scripting

greping word after new line character

how grep all user from the below looking file: User_Alias ADMIN1 = horacel, matthes, caseyl, alexl2, \ jackl, johnnyzh, maheshm, jihuih, davidw, \ christh, williaml,jasminez User_Alias ADMIN2 = tomc, apitssc, fengh, guh, kail,... (10 Replies)
Discussion started by: manojit123
10 Replies

4. UNIX for Dummies Questions & Answers

Greping next line after grep match

Hi All I have a file with tha same line multiple times and its easy to grep out those lines using grep "pattern" filealthough I need to know exactly what the next line after those lines are Can anyone please shed some light on this on how i can simultaneously grep the pattern and the next line... (9 Replies)
Discussion started by: pawannoel
9 Replies

5. Shell Programming and Scripting

line separate (pls)

Hello everybody I made code to move some files to another place for example(I moved MM file TO BIN folder ) and the MM path I put it in different file e.g(0:HOME/unixstuff/MM) so my question is who I can separate the path line and use the number 0: and MM as parameter because if I want to... (2 Replies)
Discussion started by: falm
2 Replies

6. Shell Programming and Scripting

How to get it in single line. pls help

Hi, when i am executing this script, i am getting the values of TID and Intime in different lines. How can i print both output values in a single line. please advise _____________________________ #!/bin/ksh export Path="/abc/def/ghi"; Home="/abc/jkl/prt"; cd $Path cat $Home | while read... (3 Replies)
Discussion started by: Prat007
3 Replies

7. Shell Programming and Scripting

Greping columns data from file.

Hi i am using shell script which perform oracle database query and after that output is redirect to some temporary file. the output of this file looks like SQL*Plus: Release 10.2.0.2.0 - Production on Tue Aug 5 16:08:06 2008 Copyright (c) 1982, 2005, Oracle. All Rights Reserved. ... (6 Replies)
Discussion started by: esungoe
6 Replies

8. UNIX for Advanced & Expert Users

search a replace each line- help needed ASAP

can someone help me with the find and replace command. I have a input file which is in the below format: 0011200ALN00000000009EGYPT 000000000000199900000 0011200ALN00000000009EGYPT 000000000000199900000 0011200ALN00000000008EGYPT 000000000000199800000 0011200ALN00000000009EGYPT ... (20 Replies)
Discussion started by: bsandeep_80
20 Replies

9. Shell Programming and Scripting

problem in greping the string from file using awk

I am using awk command for greping an value from the file the file contains .. file ---------------------------- content----------- -------- String main = "81507066666"; ------------------------------ i am greping the above value using awk command NumberToReplace=`cat "file" | grep... (1 Reply)
Discussion started by: vastare
1 Replies

10. Shell Programming and Scripting

greping date in a file

i have a script that checks inside the file and find the start date and end date with time........... #!/bin/ksh cd /ednadtu3/u01/pipe/logs TZ=`date +%Z`+24 ;b=`date +%Y-%m-%d` echo $b for i in DBMaint.log do echo "Start Time:" >> /ednadtu3/u01/pipe/naveed/Report.txt cat $i | grep... (3 Replies)
Discussion started by: ali560045
3 Replies
Login or Register to Ask a Question