Visit Our UNIX and Linux User Community


Desired Format !


 
Thread Tools Search this Thread
Operating Systems HP-UX Desired Format !
# 1  
Old 02-20-2008
Desired Format !

Hi everybody,

I just need desired ouput from text file which should have folowing format;

"2007-06-25 00:03:32.926+05:30",12354369,"Load","Completed","Rs.-5,556.00",9452217714
"2007-06-25 00:06:57.357+05:30",12354371,"Load","Completed","Rs.-56.00",9415766266
"2007-06-25 00:10:12.193+05:30",12354373,"Load","Completed","Rs.-56.00",9452265924
"2007-06-25 00:14:09.609+05:30",12354381,"Load","Completed","Rs.-112.00",9415732860
"2007-06-25 00:14:41.411+05:30",12354383,"Load","Completed","Rs.-56.00",9413024237
"2007-06-25 00:15:10.034+05:30",12354385,"Load","Completed","Rs.-562.00",9450526212
"2007-06-25 00:17:35.331+05:30",12354389,"Load","Completed","Rs.-787.00",9450859494
"2007-06-25 00:18:15.653+05:30",12354393,"Load","Completed","Rs.-56.00",9415732860
"2007-06-25 00:21:04.704+05:30",12354399,"Load","Completed","Rs.-225.00",9460154929
"2007-06-25 00:22:20.058+05:30",12354403,"Load","Completed","Rs.-225.00",9413521298

And coming to contents of text file are as follows;

"Date","Trans ID","MSISDN","Name","Type","State","Amount","Target MSISDN","Target Name","Pre Balance","Post Balance","IN Result","Result"
"2007-06-25 00:03:13.61+05:30",12354367,9414080537,,"Balance","Completed",,,,,,,
"2007-06-25 00:03:32.926+05:30",12354369,9450950953,"RAJESH KUMAR","Load","Completed","Rs.-5,556.00",9452217714,,"Rs.1,877.00","Rs.1,821.00",,
"2007-06-25 00:06:57.357+05:30",12354371,9452381188,"Pankaj Mansinghwani","Load","Completed","Rs.-56.00",9415766266,,"Rs.1,287.00","Rs.1,231.00",,
"2007-06-25 00:10:12.193+05:30",12354373,9450942637,"Om prakash","Load","Completed","Rs.-56.00",9452265924,,"Rs.1,016.00","Rs.960.00",,
"2007-06-25 00:10:54.813+05:30",12354375,9417730005,,"Change PIN","Rolled Back",,,,,,,"Auth Retry Exceed"
"2007-06-25 00:12:08.841+05:30",12354377,9417730005,,"Balance","Rolled Back",,,,,,,"Auth Retry Exceed"
"2007-06-25 00:13:27.06+05:30",12354379,9417730005,,"Load","Rolled Back",,,,,,,"Auth Retry Exceed"
"2007-06-25 00:14:09.609+05:30",12354381,9452394267,"SAHID RASOOL","Load","Completed","Rs.-112.00",9415732860,,"Rs.1,338.00","Rs.1,226.00",,

And i have fired the following command;

grep '"Load","Completed"' 2007-06-25_Transaction_1.txt | sed 's/,,$//g' | cut -d"," -f1,2,5-8 | head

But i am not getting concern output;

"2007-06-25 00:03:32.926+05:30",12354369,"Load","Completed","Rs.-5,556.00",missingsomecolumn
"2007-06-25 00:06:57.357+05:30",12354371,"Load","Completed","Rs.-56.00",9415766266
"2007-06-25 00:10:12.193+05:30",12354373,"Load","Completed","Rs.-56.00",9452265924
"2007-06-25 00:14:09.609+05:30",12354381,"Load","Completed","Rs.-112.00",9415732860
"2007-06-25 00:14:41.411+05:30",12354383,"Load","Completed","Rs.-56.00",9413024237
"2007-06-25 00:15:10.034+05:30",12354385,"Load","Completed","Rs.-562.00",9450526212
"2007-06-25 00:17:35.331+05:30",12354389,"Load","Completed","Rs.-787.00",9450859494
"2007-06-25 00:18:15.653+05:30",12354393,"Load","Completed","Rs.-56.00",9415732860
"2007-06-25 00:21:04.704+05:30",12354399,"Load","Completed","Rs.-225.00",9460154929
"2007-06-25 00:22:20.058+05:30",12354403,"Load","Completed","Rs.-225.00",9413521298

Could you pls help me on this at the earliest?

Best Regards!
Prasanth Babu
# 2  
Old 02-20-2008
Hammer & Screwdriver Extra comma

While a csv file can understand to ignore a comma inside quotes, grep will not.
....,"Rs.-5,556.00",....

The grep command will parse this as two fields.

Hence, the missing entry.

Previous Thread | Next Thread
Test Your Knowledge in Computers #167
Difficulty: Easy
The Transmission Control Protocol (TCP) is one of the least used protocols of the Internet protocol suite.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Desired Date format

I need to get the current year for the files that has been created today. Ex- when i list in unix console it shows ls -l abc.txt -rw-rw-r-- 1 user1 user1 33 May 2 08:58 abc.txt but i need to get as May 2 2013 , i dont need 08:58 is there any command to list it out in that... (7 Replies)
Discussion started by: Prashanth B
7 Replies

2. UNIX for Dummies Questions & Answers

How to print the line from the file in the desired format:?

I am reading a file of Linux ( like mentioned below) & the data is represented in a single line like mentioned below: 11/03 4:00 39992 0.098 5.195 0.034 0.001 1.091 182 0.000 0 0.071 4.252 0.033 0.001 666.53 Now i want to print the result in other file something like this :- 39992... (5 Replies)
Discussion started by: Anamica
5 Replies

3. UNIX for Dummies Questions & Answers

Help me in getting the desired result

Hi All, I have input file which is pipe delimited A | 1 B | 2 c | 3I need output of displaying total number of lines in a file as last column. A | 1 | 3-----total number of linesin file. B | 2 | 3 c | 3 | 3 (9 Replies)
Discussion started by: pravinashwin
9 Replies

4. UNIX for Dummies Questions & Answers

Help with saving file in desired format

Hi I have the following file in the unix named emp. ID,NAME,SAL,DEPT 101,aaa,2000,10 102,bbb,3000,20 103,ccc,4000,30 104,ddd,5000,40 105,aaa,2000,50 106,bbb,3000,60 107,ccc,4000,70 108,ddd,5000,10 109,aaa,2000,80 I need to save first 3 columns(ID, NAME, SAL) in another file with... (2 Replies)
Discussion started by: alok3141
2 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

Need your help to get the output of the list in desired format

Hello Guys, I am working on a script and using the below code to fetch the list of all repositories CHDIR='/mnt/scm/subversion/' repolist() { cd ${CHDIR} Repo=`ls|cut -d " " -f1` echo $Repo } Output of the above code is BSB CIB COB DCI DIB DSB ESB-P ESB-TOOLS FareVerify GCACHE GWY... (15 Replies)
Discussion started by: rohit22hamirpur
15 Replies

7. 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

8. 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

9. UNIX for Advanced & Expert Users

get the timestamp of a file in desired format

Hi, I have a file say abc. I get the timestamp in following way: ls -ltr abc | awk -F" " '{print $6,$7,$8}' Mar 8 10:23 I need to get the timestamp as : 03-08-2007 10:23:00 Thanks Sumeet (1 Reply)
Discussion started by: sumeet
1 Replies

10. UNIX for Dummies Questions & Answers

capturing the time stamp in desired format

Hello All, I am working on korn shell script.i have 2 questions; 1) I have a file and i am able to capture the arrival time. the arrival time is capturing as 11:30 ls -ltr aaa.bbb.332121312.*.* | awk -F" " '{print $8}' 11:30 my desired output is 113000 can anyone please suggest me... (2 Replies)
Discussion started by: pavan_test
2 Replies

Featured Tech Videos