Changing display format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Changing display format
# 1  
Old 12-01-2010
Changing display format

Hi,

My file
Code:
cat a.txt
       Sat Nov 27 00:02:00 2010
00:02:00 Usr    27: Login by edi on batch. (452)
00:02:09 Usr    27: Logout by  on batch. (453)
00:02:09 Usr    27: Login by edi on batch. (452)
00:02:22 Usr    27: Logout by  on batch. (453)
00:02:22 Usr    27: Login by edi on batch. (452)
00:02:28 Usr    27: Logout by  on batch. (453)
00:02:28 Usr    27: Login by edi on batch. (452)
00:02:34 Usr    27: Logout by  on batch. (453)
00:02:35 Usr    27: Login by edi on batch. (452)
00:02:42 Usr    27: Logout by  on batch. (453)
00:02:42 Usr    27: Login by edi on batch. (452)
00:02:48 Usr    27: Logout by  on batch. (453)
00:02:48 Usr    27: Login by edi on batch. (452)
00:02:58 Usr    27: Logout by  on batch. (453)
00:02:58 Usr    27: Login by edi on batch. (452)
00:03:04 Usr    27: Logout by  on batch. (453)
00:50:01 Usr    27: Login by mfg on batch. (452)
00:51:18 Usr    27: Logout by  on batch. (453)
02:00:01 Usr    27: Login by mfg on batch. (452)
02:00:24 Usr    27: Logout by  on batch. (453)
03:00:01 Usr    27: Login by mfg on batch. (452)
03:00:56 Usr    27: Logout by  on batch. (453)
   Sun Nov 28 00:50:00 2010
00:50:00 Usr    27: Login by mfg on batch. (452)
00:51:23 Usr    27: Logout by  on batch. (453)
02:00:00 Usr    27: Login by mfg on batch. (452)
02:00:23 Usr    27: Logout by  on batch. (453)
03:00:00 Usr    27: Login by mfg on batch. (452)
03:00:55 Usr    27: Logout by  on batch. (453)
03:29:01 Usr    27: Login by root on batch. (452)
03:29:03 Usr    27: Logout by  on batch. (453)
 Mon Nov 29 00:50:00 2010
00:50:00 Usr    27: Login by mfg on batch. (452)
00:51:23 Usr    27: Logout by  on batch. (453)
02:00:00 Usr    27: Login by mfg on batch. (452)
02:00:23 Usr    27: Logout by  on batch. (453)
03:00:00 Usr    27: Login by mfg on batch. (452)
03:00:55 Usr    27: Logout by  on batch. (453)
03:29:01 Usr    27: Login by root on batch. (452)
03:29:03 Usr    27: Logout by  on batch. (453)

Expected output
Code:
       Sat Nov 27 00:02:00 2010 00:02:00 Usr    27: Login by edi on batch. (452)
       Sat Nov 27 00:02:00 2010 00:02:09 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 00:02:09 Usr    27: Login by edi on batch. (452)
       Sat Nov 27 00:02:00 2010 00:02:22 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 00:02:22 Usr    27: Login by edi on batch. (452)
       Sat Nov 27 00:02:00 2010 00:02:28 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 00:02:28 Usr    27: Login by edi on batch. (452)
       Sat Nov 27 00:02:00 2010 00:02:34 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 00:02:35 Usr    27: Login by edi on batch. (452)
       Sat Nov 27 00:02:00 2010 00:02:42 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 00:02:42 Usr    27: Login by edi on batch. (452)
       Sat Nov 27 00:02:00 2010 00:02:48 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 00:02:48 Usr    27: Login by edi on batch. (452)
       Sat Nov 27 00:02:00 2010 00:02:58 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 00:02:58 Usr    27: Login by edi on batch. (452)
       Sat Nov 27 00:02:00 2010 00:03:04 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 00:50:01 Usr    27: Login by mfg on batch. (452)
       Sat Nov 27 00:02:00 2010 00:51:18 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 02:00:01 Usr    27: Login by mfg on batch. (452)
       Sat Nov 27 00:02:00 2010 02:00:24 Usr    27: Logout by  on batch. (453)
       Sat Nov 27 00:02:00 2010 03:00:01 Usr    27: Login by mfg on batch. (452)
       Sat Nov 27 00:02:00 2010 03:00:56 Usr    27: Logout by  on batch. (453)
       Sun Nov 29 00:50:00 2010 00:50:00 Usr    27: Login by mfg on batch. (452)
       Sun Nov 29 00:50:00 2010 00:51:23 Usr    27: Logout by  on batch. (453)
       Sun Nov 29 00:50:00 2010 02:00:00 Usr    27: Login by mfg on batch. (452)
       Sun Nov 29 00:50:00 2010 02:00:23 Usr    27: Logout by  on batch. (453)
       Sun Nov 29 00:50:00 2010 03:00:00 Usr    27: Login by mfg on batch. (452)
       Sun Nov 29 00:50:00 2010 03:00:55 Usr    27: Logout by  on batch. (453)
       Sun Nov 29 00:50:00 2010 03:29:01 Usr    27: Login by root on batch. (452)
       Sun Nov 29 00:50:00 2010 03:29:03 Usr    27: Logout by  on batch. (453)
       Mon Nov 29 00:50:00 2010 00:50:00 Usr    27: Login by mfg on batch. (452)
       Mon Nov 29 00:50:00 2010 00:51:23 Usr    27: Logout by  on batch. (453)
       Mon Nov 29 00:50:00 2010 02:00:00 Usr    27: Login by mfg on batch. (452)
       Mon Nov 29 00:50:00 2010 02:00:23 Usr    27: Logout by  on batch. (453)
       Mon Nov 29 00:50:00 2010 03:00:00 Usr    27: Login by mfg on batch. (452)
       Mon Nov 29 00:50:00 2010 03:00:55 Usr    27: Logout by  on batch. (453)
       Mon Nov 29 00:50:00 2010 03:29:01 Usr    27: Login by root on batch. (452)
       Mon Nov 29 00:50:00 2010 03:29:03 Usr    27: Logout by  on batch. (453)

Please help me to fix this issue.

Last edited by Scott; 12-01-2010 at 06:52 PM.. Reason: Please use code tags
# 2  
Old 12-01-2010
This is a Progress Database log and the layout as posted does not exactly match such a log format.
Please post the log in Code Tags.


Off topic. The absence of a username on the "Logout" lines is ominous. I've only seen that effect after exceeding the licence.
# 3  
Old 12-01-2010
try:
Code:
awk ' $1 ~ /^[SMTWF]/ { start=$0 ; next} {print start, $0} ' inputfile

# 4  
Old 12-01-2010
Code:
 awk ' NF==5 { gsub(/^ */,"");start=$0 ; next} {print start,$0} ' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing Date Format

How can i make the date command output yesterday's date, current date and the date 4 days ago, in the following format: 2012-10-03 code: date +% ???? (3 Replies)
Discussion started by: SkySmart
3 Replies

2. Shell Programming and Scripting

changing all the lines in one format

Hi, I am beginner. have almost one text file which contains 6000 lines. every line is in different format.so need to rearrange in single format. Ex: .thde.adgtmk.802ati thde.kghijk..567ati ..thde.kghijk..458ati thde.ertyui.456.567.789ati thde.awse.dati Rules:... (2 Replies)
Discussion started by: kartheek
2 Replies

3. UNIX for Dummies Questions & Answers

Changing from Excel date format to MySQL date format

I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd. The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4". This is what I use to change the format: sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies

4. Shell Programming and Scripting

Changing the output in own time display's.

Hi all, I've written a script which collects some information and sendsout a mail.. (code pasted below) ssh -l ora${sid} ${primaryhost} "tail -50 /oracle/$ORACLE_SID/newbackup/END_BACKUP.log" |grep 'insert' |tail -1| awk '{print $7}' >> ${RESULTFILE} Output would look like this:... (1 Reply)
Discussion started by: suri.tyson
1 Replies

5. Shell Programming and Scripting

changing month in Mmm format to mm FORMAT

i have an variable mydate=2008Nov07 i want o/p as in variable mymonth=11 (i.e nov comes on 11 number month) i want some command to do this for any month without using any loop. plz help me (1 Reply)
Discussion started by: RahulJoshi
1 Replies

6. UNIX for Dummies Questions & Answers

Changing display and format of file

I have an input file which looks like this: 601 a 602 a 603 a 601 b 610 c 615 c 603 d 601 d 612 d I need the utput to look like this 601 a 602 603 602 a 601 603 603 a 601 602 601 b 610 c 615 615 c 610 603 d 601 612 (1 Reply)
Discussion started by: wahi80
1 Replies

7. Shell Programming and Scripting

changing format

Dear Experts, Currently my script is gereating the output like this as mentioned below. 8718,8718,0,8777 7450,7450,0,7483 5063,5063,0,5091 3840,3840,0,3855 3129,3129,0,3142 2400,2400,0,2419 2597,2597,0,2604 3055,3055,0,3078 4249,4249,0,4266 4927,4927,0,4957 8920,8920,0,8978... (4 Replies)
Discussion started by: shary
4 Replies

8. UNIX for Dummies Questions & Answers

Changing the format of date

Hi, There are lots of threads about how to manipulate the date using date +%m %....... But how can I change the default format of the commad date? $ date Mon Apr 10 10:57:15 BST 2006 This would be on fedora and SunOs. Cheers, Neil (4 Replies)
Discussion started by: nhatch
4 Replies

9. Shell Programming and Scripting

Changing date format

Hi, Is there any way to change one date format to another ?? I mean I have a file having dates in the format (Thu Sep 29 2005) ... and i wud like to change these to YYYYMMDD format .. is there any command which does so ?? Or anything like enum which we have in C ?? Thanks in advance, ... (5 Replies)
Discussion started by: Sabari Nath S
5 Replies
Login or Register to Ask a Question