help in extracting logs in readable format


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help in extracting logs in readable format
# 1  
Old 08-29-2011
help in extracting logs in readable format

hello everyone. newbie here in unix. I am trying to extract the logs of a certain job and would like to output it in a readable format, see below the CAT part:


cat /var/opt/ctma/ctm/sysout/idwesct_sh30_eng_r6_cdcs_sh.LOG_05l0du_000* | egrep -i 'orderid:|file_name=' | sed "s/SH30_READ_FILE_NAME=\/var\/opt\/idwe\/data\/in//" | sed '/^LOG/ d' | sed "s/new ORDER created, orderid:0//" > /home/me/FILE

the output would be like this:

$ cat FILE
/sh30/sdt/EGDO0120110828180106
5l53d(9384457) for JOBNAME=IDWEJ77252.
/sh30/sdt/LVDO0120110828180102
5l53e(9384458) for JOBNAME=IDWEJ77332.
/sh30/sdt/RODO0120110828180111
5l53f(9384459) for JOBNAME=IDWEJ77333.

However, I want it to be in readable format such as this:
5l53d /sh30/sdt/EGDO0120110828180106
5l53e /sh30/sdt/LVDO0120110828180102
5l53f /sh30/sdt/RODO0120110828180111

So basically, I only need the first 5 characters of the 2nd, 4th, 6th, etc lines, and the whole line for the 1st, 3rd, 5th and so on...

although I was able to do this but using two files, that is all the 2nd, 4th, 6th lines is in one file, and the 1st, 3rd, 5th lines is in another file then just used the SDIFF to join them side by side... but I am thinking if there is still a more suitable way on how to do this..

your inputs are highly appreciated!Smilie
# 2  
Old 08-29-2011
First off, that's a useless use of cat. Any program in UNIX which uses stdin is fully capable of reading files without being spoon-fed by cat. program < filename or <filename program | program2 ...

If you have a modern enough shell, how about this:

Code:
while read LINE
do
        read LINE2
        echo "${LINE2:0:5}" "${LINE}"
done < data

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting a random epoch time into a readable format

I am trying to create a script that will take epoch (input from command line) and convert it into a readable format in bash/shell ---------- Post updated at 08:03 PM ---------- Previous update was at 07:59 PM ---------- #!bin/bash read -p "Please enter a number to represent epoch time:"... (9 Replies)
Discussion started by: sprocket
9 Replies

2. Shell Programming and Scripting

Readable passwords in logs

I'm looking for two scripts, can anyone help me on this. The first one to scan log files in /xxxx/xxxx/xxxx/USERLOGS and /xxxx/xxxxx/xxx/xxx/xxx/Logs and list out all files and the offending lines that have a readable password. Check the accuracy of the script to see if it is missing lines... (5 Replies)
Discussion started by: shivamayam
5 Replies

3. Shell Programming and Scripting

Arranging Haphazard output in readable format

Dear Friends, Need your help once again. I have a sql to download output in pipe separated format. Due to that output looks haphazard. E.G. $cat output.temp 123|456|789|0 67345123||3455|1 7124563|432343414||345324 By any was can we arrange it in tabular format for better... (4 Replies)
Discussion started by: anushree.a
4 Replies

4. UNIX for Dummies Questions & Answers

Display Directories with their sizes in human readable format

Hi, I want to list all the directories present in a particular location and want to display their sizes as well. I know "ls -lh" but it doesn't show the size of the complete directory. So i want something like dir1 266 MB dir2 2 KB dir3 22 MB ... ... file1 10 Kb ..... Thanks Sarbjit (4 Replies)
Discussion started by: sarbjit
4 Replies

5. UNIX for Dummies Questions & Answers

vmstat in a better readable format

Dear All: Is there a way to nicely format the vmstat output: #3sec interval, 5 measurements vmstat 3 5 It prints out all the good info but not in a very readable format. Any help, advise, suggestion will be highly appreciated. Thanks. (1 Reply)
Discussion started by: tom_k_mishra
1 Replies

6. UNIX for Dummies Questions & Answers

Converting binary file to readable format in Ksh

In Unix/Ksh, when I try to look inside a file it says that the file may be a binary file and if I want to see it anyway. When i say 'yes', it shows me the content filled with unreadable symbols (looks like binary). Is there a command that I can run from the Unix prompt to convert/translate that... (3 Replies)
Discussion started by: arthurs
3 Replies

7. Shell Programming and Scripting

convert unix date to readable format

Dear Experts, I need your help to convert a unix date and time format number in to readable format like dd/mm/yyyy . I have a text file of more than 10,000 records and it is like NAME DATE1 COUNTRY DATE2 ABD 1223580395699 USA 1223580395699... (3 Replies)
Discussion started by: shary
3 Replies

8. HP-UX

file in malibox is readable format?

Hi, Files coming to mailbox are in readable format? Is there any special command to read these files. suppose i have sent a file like this megh$mailx -s "mesg" xyz@server.domain<file1.dat can xyz directly read the file from his mailbox? (1 Reply)
Discussion started by: megh
1 Replies

9. Programming

converting unix timestamp into readable format using c++

hi everyone, im new here and am in desperate need of help. I want to convert my 32 bit unix time stamp ' 45d732f6' into a readable format (Sat, 17 February 2007 16:53:10 UTC) using c++. I have looked around the interent but i just cant make sense of anything. All examples i can find just... (3 Replies)
Discussion started by: uselessprog
3 Replies

10. UNIX for Dummies Questions & Answers

To convert multi format file to a readable ascii format

Hi I have a file which has ascii , binary, binary decimal coded,decimal & hexadecimal data with lot of special characters (like öƒ.ƒ.„İİ¡Š·œƒ.„İİ¡Š· ) in it. I want to standardize the file into ASCII format & later use that as source . Can any one suggest a way a logic to convert such... (5 Replies)
Discussion started by: gaur.deepti
5 Replies
Login or Register to Ask a Question