How to grep the content performed by an User


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to grep the content performed by an User
# 1  
Old 08-10-2012
Error How to grep the content performed by an User

I want to grep the content performed by an User from a file. Suppose that i have a following file
Code:
HYD-HMS-2$ ls -lrt
-rw-r--r--   1 sdfrun   sdf   31726356 Aug  1 13:04 journal.03.01082012.19.csv

I could able to grep the content performed by a user by "sed" command as follows

Code:
HYD-HMS-2$ cat journal.03.01082012.19.csv | sed 's/^dn:/@dn:/g'|tr -d '\n'|tr -s '@' '\n'|grep 'venkat'
dn: hlrServ=common,serviceName=hlr,id=00 08 02 CA C8 C5 4B E9 36 07 00 00,domainName=subsD,o=TTSL,c=INchangetype: modifyreplace: checkSSIndcheckSSInd: FALSE# checkSSInd: FALSE-replace: netRegBarnetRegBar: FALSE# netRegBar: FALSE-replace: orProvorProv: FALSE# orProv: FALSE-replace: naeaProvnaeaProv: FALSE# naeaProv: FALSE-replace: partnerImsiProvpartnerImsiProv: FALSE# partnerImsiProv: FALSE-replace: callPartyCatcallPartyCat: 10# callPartyCat: 10-replace: ptnrNetworkIndexptnrNetworkIndex: 0# ptnrNetworkIndex: 0-replace: ftnTransIndexftnTransIndex: 1# ftnTransIndex: 1-replace: hplmnRefhplmnRef: 1# hplmnRef: 1-replace: naeaPrefCarrierIdnaeaPrefCarrierId: 0# naeaPrefCarrierId: 0-replace: accessRestrictionDataaccessRestrictionData: '00000000'B# accessRestrictionData: '10000000'B-replace: profileIndexprofileIndex: 1# profileIndex: 1-replace: netAccModenetAccMode: nonGPRSandGPRS# netAccMode: nonGPRSandGPRS-# entryIndex: 5104896# parentIndex: 5104924# entryUpdateCounter: 3685# dsTid: 4166168458 $ 2# userInvokeId: ffffffc1ffffffbd# updateId: 01/08/2012 13:01:50 $ $ 749094677# user: venkat# userTransactionId: 00000c00# updateStatus: success
dn: hlrServ=common,serviceName=hlr,id=00 08 02 CA C8 C5 4B E9 36 07 00 00,domainName=subsD,o=TTSL,c=INchangetype: modifyreplace: checkSSIndcheckSSInd: FALSE# checkSSInd: FALSE-replace: netRegBarnetRegBar: FALSE# netRegBar: FALSE-replace: orProvorProv: FALSE# orProv: FALSE-replace: naeaProvnaeaProv: FALSE# naeaProv: FALSE-replace: partnerImsiProvpartnerImsiProv: FALSE# partnerImsiProv: FALSE-replace: callPartyCatcallPartyCat: 10# callPartyCat: 10-replace: ptnrNetworkIndexptnrNetworkIndex: 0# ptnrNetworkIndex: 0-replace: ftnTransIndexftnTransIndex: 1# ftnTransIndex: 1-replace: hplmnRefhplmnRef: 1# hplmnRef: 1-replace: naeaPrefCarrierIdnaeaPrefCarrierId: 0# naeaPrefCarrierId: 0-replace: accessRestrictionDataaccessRestrictionData: '10000000'B# accessRestrictionData: '00000000'B-replace: profileIndexprofileIndex: 1# profileIndex: 1-replace: netAccModenetAccMode: nonGPRSandGPRS# netAccMode: nonGPRSandGPRS-# entryIndex: 5104896# parentIndex: 5104924# entryUpdateCounter: 3686# dsTid: 4166181942 $ 2# userInvokeId: ffffffc1ffffffbd# updateId: 01/08/2012 13:02:29 $ $ 749108161# user: venkat# userTransactionId: 00000c00# updateStatus: success
HYD-HMS-2$

But I want the output to be displayed as follows instead of above format

Code:
dn: hlrServ=common,serviceName=hlr,id=00 08 02 CA C8 C5 4B E9 36 07 00 00,domainName=subsD,o=TTSL,c=IN
changetype: modify
replace: checkSSInd
checkSSInd: FALSE
# checkSSInd: FALSE
-
replace: netRegBar
netRegBar: FALSE
# netRegBar: FALSE
-
replace: orProv
orProv: FALSE
# orProv: FALSE
-
replace: naeaProv
naeaProv: FALSE
# naeaProv: FALSE
-
replace: partnerImsiProv
partnerImsiProv: FALSE
# partnerImsiProv: FALSE
-
replace: callPartyCat
callPartyCat: 10
# callPartyCat: 10
-
replace: ptnrNetworkIndex
ptnrNetworkIndex: 0
# ptnrNetworkIndex: 0
-
replace: ftnTransIndex
ftnTransIndex: 1
# ftnTransIndex: 1
-
replace: hplmnRef
hplmnRef: 1
# hplmnRef: 1
-
replace: naeaPrefCarrierId
naeaPrefCarrierId: 0
# naeaPrefCarrierId: 0
-
replace: accessRestrictionData
accessRestrictionData: '10000000'B
# accessRestrictionData: '00000000'B
-
replace: profileIndex
profileIndex: 1
# profileIndex: 1
-
replace: netAccMode
netAccMode: nonGPRSandGPRS
# netAccMode: nonGPRSandGPRS
-
# entryIndex: 5104896
# parentIndex: 5104924
# entryUpdateCounter: 3686
# dsTid: 4166181942 $ 2
# userInvokeId: ffffffc1ffffffbd
# updateId: 01/08/2012 13:02:29 $ $ 749108161
# user: venkat
# userTransactionId: 00000c00
# updateStatus: success

can someone help me to get the desired output. I am attaching the txt file for your easy reference.

Moderator's Comments:
Mod Comment Please view this code tag video for how to use code tags when posting code and data.

Last edited by Corona688; 08-10-2012 at 10:08 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep content between specific lines

cat file1 *FileHeader* Partition 0 Total Data Bytes 1416 Avg Bytes/Record 1416 Others 1 PRDX22.AUDIT_DATA_INFO Partition 4 Total Data Bytes 4615 Avg... (8 Replies)
Discussion started by: Veera_V
8 Replies

2. UNIX for Dummies Questions & Answers

Grep content in xml file

I have an xml file with header as below. <Provider xmlns="http://www.xyzx.gov/xyz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xyzx.gov/xyz xyz.xsd" SCHEMA_VERSION="2.5" PROVIDER="5"> I want to get the schema version here that is 2.5 and put in a... (7 Replies)
Discussion started by: Ariean
7 Replies

3. Red Hat

Master logs for all the operations performed on mysql DB

is there any such thing as master logs for all the operations performed on mysql database. thing is i need to find the operations performed on mysql on a linux server running on RHEL 5.7 for the past 2 days. One more thing i found out that the bin logs will be refreshed whenever server goes to... (2 Replies)
Discussion started by: vivek d r
2 Replies

4. UNIX for Dummies Questions & Answers

System administration tasks performed from a menu driven interface

I need to write a shell script that allows some system-administration tasks to be preformed automatically from a menu-driven interface. Automate the following tasks: • Copy directory tree • Delete files or directories • Output Information But I don't understand the question. What is a "menu... (2 Replies)
Discussion started by: femchi
2 Replies

5. Shell Programming and Scripting

how to get tags content by grep

1) Is it possible to get tags content by grep -E ? For example title. Source text "<title>My page<title>"; to print "My page". 2) which bash utility to use when I want to use regex in this format? (?<=title>).*(?=</title) (11 Replies)
Discussion started by: visitor123
11 Replies

6. Shell Programming and Scripting

grep variable with tricky content

Hello, i have this issue: text="-8x7YTVNk2KiuY-PWG5zzzjB-zzw" string=-8x7YTVNk2KiuY-PWG5zzzjB-zzw echo $text | grep -v \'$string\' -8x7YTVNk2KiuY-PWG5zzzjB-zzw echo \'$string\' '-8x7YTVNk2KiuY-PWG5zzzjB-zzw' ..and ofcourse if I do like this : echo $text | grep -v $string grep: invalid... (5 Replies)
Discussion started by: black_fender
5 Replies

7. UNIX for Dummies Questions & Answers

logs of commands performed by users

Hi, when 2 users are logged as root , how can i find witch one had perform witch command? Thanks, (1 Reply)
Discussion started by: prpkrk
1 Replies

8. AIX

smit see comand performed ??

i in smit , press F6 , smit fs , Change / Show Characteristics of an Enhanced Journaled File System then F6 to see the comand , how can i see the command performed ?? x() { │ │ LIST= ... (5 Replies)
Discussion started by: prpkrk
5 Replies

9. Shell Programming and Scripting

Grep content between timestamp

Hi all, I have a file which will be updated every half an hour and time stamp will be printed in the beginning of the updation. i just want to grep the content between every hoalf an hour. Pls help me on this issue. how to grep contents between tim stamp? Ex of file: 29/09/2010... (20 Replies)
Discussion started by: steve2216
20 Replies

10. UNIX for Dummies Questions & Answers

How can we grep only those content according to regular expression

I try to collect first those content like <w c5=".*" hw=".*" pos=".*?">.*</w> in that A00.xml. I use the following pattern : egrep "<w c5=".*" hw=".*" pos=".*?">.*</w>" A00.xml The result is: <s n="396"><w c5="PNP" hw="we" pos="PRON">We </w><w c5="VVB" hw="make" pos="VERB">make </w><w... (3 Replies)
Discussion started by: Johnivy
3 Replies
Login or Register to Ask a Question