ext File


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ext File
# 1  
Old 05-21-2012
ext File

I have a log file that I want to extract the field name and the field value
and write them to a text file for importation it a database table for reporting purposes.

How can I extract the desired data from this file .

Example: dbt_dbid=4

dbt_dbid is the field name
4 is the field value



Code:
1> use master
1> dbcc traceon(3604)
DBCC execution completed. If DBCC printed error messages, contact a user with
System Administrator (SA) role.
1> dbcc dbtable("TestDB")
DBTABLES (ACTIVE):
DB Table at: 0x0000000021986BA0
 
dbt_dbid=4   dbt_stat=0x0 (0x0000)
dbt_extstat=0x0 (0x0000)
dbt_stat2=0x0 (0x0000)
dbt_stat3=0x20000 (0x00020000 (DBT3_SYSPARTITIONS_EXISTS))
dbt_stat4=0x0 (0x00000000)
dbt_runstat=0x0(0x0000)
dbt_state=0x2(0x0002 (DBST_ACTIVE))   dbt_keep=0  dbt_hdeskeep=0
dbt_next=0x000000002197DE80   dbt_systask_keep=0 dbt_detachxact_keep 0
 dbt_dcompver_default=1
dbt_lock=0  dbt_dbaid=1
dbt_verstimestamp= May 15 2012  3:37PM   dbt_dbname=TestDB
dbt_logrows=0
dbt_lastlogbp=0x0000000000000000
dbt_logsema=000000000099EE10 
dbt_nextseq=11  dbt_oldseq=11
dbt_dbinfobuf.dbi_logvers=7
dbt_dbinfobuf.dbi_upgdvers=35 ... .dbi_upgd_minor=1720
dbt_dbinfobuf.dbi_dbinfovers=5
dbt_dbinfobuf.dbi_sarg_vers=2  dbt_threshstat=0x0
dbt_thresholds=0x00000000219873B8  dbt_thresh_spin=0x000000002011E300
dbt_maxthresh=256
thc_segment   2 thc_level   664 thc_status 0xf <-- last chance threshold
dbt_nextid=560001995 dbt_nextidstat=0x0
dbt_dflinfo=0x0000000000000000  dbt_dflstat=0x0
dbt_dumpthreadlock=0
dbt_dbts=0x0000 0x00001492   dbt_xdesqueue   next=0x0000000021986C20
prev=0x0000000021986C20
dbt_xdesqueue_spin=0x000000002011E100


Last edited by JolietJake; 05-21-2012 at 11:27 AM..
# 2  
Old 05-21-2012
If I understood it correct:
Code:
awk -F"[= \t]+" '/dbt_dbid/ {print $1,$2}' infile > newfile


Last edited by zaxxon; 05-21-2012 at 11:38 AM..
# 3  
Old 05-21-2012
Generating a list of fields and values

How would I go about retrieving all the fields that begin with
dbt_xxxxxxxx= in the file and generating a file with every field
listed.
# 4  
Old 05-21-2012
Like this?
Code:
# awk -F"[= \t]+" '/^dbt_/ {print $2}' infile
4
0x0
0x0
0x20000
0x0
0x0(0x0000)
0x2(0x0002
0x000000002197DE80
0
May
0
0x0000000000000000
000000000099EE10
11
7
35
5
2
0x00000000219873B8
256
560001995
0x0000000000000000
0
0x0000
0x000000002011E100

If you want the name, add $1 to the print. If you want it redirected, use "> newfile" like in the example before.
# 5  
Old 05-21-2012
More than one field per line

This file is not formatted with one record(field) on each line
in some instances the more than one field is on the same line
Example: dbt_verstimestamp= May 15 2012 3:37PM dbt_dbname=TestDB

SO how would I grab the date 'May 15 2012 3:37PM' and grab the field dbt_dbname and it valur 'TestDB'

then read the next field.
with the file formated with more than one field on each line I think the delimiter for the next field would be
dbt_

SO how would I modify the script to account for that
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. IP Networking

One router, 2 machines, to OS, 2 different ext. IP's?

I even don't dare to ask for a hint, but as I am looking for clues may someone can help me, though reading me bsd handbook. It is about one machine running as media play studio with a debian distro and one machine running bsd 10.2 connected to one router. By booting first the debian machine it... (4 Replies)
Discussion started by: 1in10
4 Replies

2. Shell Programming and Scripting

Log ext

I have a script that does log rotation, at 10000k, it will print out the logs as follows: name.date.0.log(1gb) name.date.1.log(1gb) name.date.2.log(200mb) << current log being written to at midnight it reverts back to : name.date.0.log(size) I want it to be able to go past date.9.log... (2 Replies)
Discussion started by: bigbenn
2 Replies

3. Shell Programming and Scripting

Script to monitor for new file with ext .err and size > 0 bytes and perform a action or command

Hi All, I need to create a script to monitor a dir for new files with ext .err and also it should b a non empty files. and perform a action or command . We have a new ETL application that runs on a linux server, every times a etl fails it creates a .err file or updates the existing .err... (4 Replies)
Discussion started by: MAKHAN
4 Replies

4. Shell Programming and Scripting

Duplicate name diff file ext

Hi All I have converted a load of files to different formats but I am now left with a folder with loads of differnt files All of them are called the same, the only differnce is the file extension (Sizes also vary so cannot do anything with MD5) example file1.abc file1.xyz file2.abc... (2 Replies)
Discussion started by: tofa83
2 Replies

5. Shell Programming and Scripting

du -s *.ext (total)

How would I get a total of a wildcard of files from the 'du' command? du -s *.pdf Result: 736 11mens_bracket.pdf 64 2011_NIT_Bracket_3_13_11.pdf 80 Doing more with Less part1.pdf 1064 Doing more with Less part2.pdf 28 Parkview_1309_Garage.pdf 3964 statsheet-bracket-2011.pdf Expected... (7 Replies)
Discussion started by: AlphaLexman
7 Replies

6. HP-UX

Limitation on *.ext

Is there a size limit when passing an argument using wildcards? I.E. when I pass an argument in the form (like) "ftp_auto *.txt" - is there a limitation on the size of UNIX expanding "*.txt" ? (1 Reply)
Discussion started by: vslewis
1 Replies

7. UNIX for Advanced & Expert Users

shred() not working on ext* file systems

When vfat format my128kb flash drive, shred works fine. But, when I format it using ext2 or ext3, shred() exits with this error: shred: /dev/sdb1: pass 1/1 (random)... shred: /dev/sdb1: error writing at offset 12288: Invalid argumentAnyone know what is going on? (0 Replies)
Discussion started by: codecellar
0 Replies

8. UNIX for Dummies Questions & Answers

Help with a ext. modem on SCO 5.0.5

I am fully capable of reading a book to get the answers or looking to the web, but no one has the answer to this one. I had a Zoom 56K V34 Plus external modem (2836A) attached to my Unix box for about ten years without a flaw. This weekend I couldn't access the box remotely through the modem and... (0 Replies)
Discussion started by: scivic
0 Replies

9. Shell Programming and Scripting

rename file to file.ext.datetime

Hi, I need to rename a file like this to include date and time: Original File : error.log Date time: Sep 20, 2007 14:10:10 New File Name: error.log.20070920_1410 How can I get date and time stame and include it in mv command. Thanks in advance (2 Replies)
Discussion started by: tripsat
2 Replies
Login or Register to Ask a Question