Trying to figure out a log dump command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Trying to figure out a log dump command
# 1  
Old 04-01-2010
Trying to figure out a log dump command

Ok so i'm relatively new at UNIX and I'm trying to figure out how to make a log dump command.

My situation is a bit odd in that I'm always looking at customers boxes and as such I can't really do much to them. So everything I do in UNIX pretty much has to be a command I can type in by hand. I can't really install any apps to do things for me or anything like that since that required modifying the customers box. So I'm limited to software on the box now. We are freebsd with Bash.

So what I'm trying to do is make a command that will pull data for a specific date and time out of a bunch of different log files in different places. Then take all that information and dump it into a single log file that I can then save and look at. Which will be a big time saver for me. So that instead of having to manually dig my way through 10 log files I can just run one command and get all the data I need made into 1 file. Then I can dig through that.

I'm sure I could just do a great big long string of.. cat /folder/file | grep 'date' >> output file.

But that would require going through the entire command each time and adjust the date and time information which is going to change constantly. So I was hoping I could find a way to use variable somehow. So that I can write the command to look at variables to determine the date and time. This way all I have to do is adjust the variables to the date and time I want and the command will work. I suspect AWK can do this but really I'm just trying to figure out what kind of ideas and options I have for doing something like this.

I would appreciate any approaches to how I could accomplish this task.

---------- Post updated at 11:25 AM ---------- Previous update was at 10:37 AM ----------

Ok so I can grep for variables which is good. And I've found how I can set the variables.
Code:
#testvariable='May'; testvariable2='june'

This will allow me to easily set any number of variables. Then I can simply grep the specific log files for date and time... Now the only snag i'm running into is I can't get multiple spaces into the date. In my logs the date is.

Apr 1

with 2 spaces not 1 and anytime I set the variable it always has 1 space. Any idea how I can get 2 spaces to work?

Last edited by Yogesh Sawant; 04-05-2010 at 09:18 AM.. Reason: added code tags
# 2  
Old 04-01-2010
Code:
testvariable3='Apr  1'
grep "${testvariable3}" filename

# 3  
Old 04-01-2010
Tried that no matter what I do it returns the variable with 1 space not 2.

Code:
#/var/log #testvariable=(Apr  2)      
#/var/log #echo $testvariable
Apr

#/var/log #testvariable=(Apr' ' ' '2)
#/var/log #echo $testvariable
Apr 2

#/var/log #testvariable=(Apr" "" "2)
#/var/log #echo $testvariable
Apr 2

#/var/log #testvariable='Apr'' ''2'
#/var/log #echo $testvariable
Apr 2
#/var/log #testvariable='Apr'' '" "'2'
#/var/log #echo $testvariable
Apr 2



---------- Post updated at 12:15 PM ---------- Previous update was at 11:45 AM ----------

Pretty much at this point this double space garbage is the only thing preventing me from getting what i want. Some of my logs are not retarded and the date is Mar 02 and some are stupid and its Mar 2 with 2 spaces.... I have go to figure out how to make it take the variable and put in two spaces.

Last edited by Yogesh Sawant; 04-05-2010 at 09:18 AM.. Reason: added code tags
# 4  
Old 04-01-2010
your last post, looks like you are not following the examples given. you need to quote your echo commands... variables with spaces always require quoting.

Code:
testvariable3='Apr 1'

tark22@fmc1xx2rqf6d1 ~/
echo "$testvariable3"

### not this #/var/log #echo $testvariable  << notice  you have no quote around variable?

example below works fine:
Code:
$ testvariable3='Apr 1'

$ echo "$testvariable3"
Apr 1

# 5  
Old 04-01-2010
OHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!

Sweetness!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. OS X (Apple)

Can't figure out the correct syntax for a command loading a webkit plugin

Hello, Using Bash on Mac OS X 10.7.5 (Lion). I downloaded a GrowlSafari plugin for Webkit from its GitHub page GitHub - uasi/growl-safari-bridge: GrowlSafariBridge enables arbitrary javascript (including Safari Extensions) to notify via Growl.. In the description it says that after installing for... (0 Replies)
Discussion started by: scrutinizerix
0 Replies

2. Shell Programming and Scripting

Help with change significant figure to normal figure command

Hi, Below is my input file: Long list of significant figure 1.757E-4 7.51E-3 5.634E-5 . . . Desired output file: 0.0001757 0.00751 0.00005634 . . . (10 Replies)
Discussion started by: perl_beginner
10 Replies

3. Shell Programming and Scripting

Is there a command to close a program with dump?

I'm running into some problems using pkill in my scripts. I'm using a program that needs to dump. (4 Replies)
Discussion started by: ninjaaron
4 Replies

4. UNIX for Dummies Questions & Answers

dump command fault

im performing the dump command : dump 0uaf /dev/hdc /home an error msg appers says: DUMP: you cant update the dumpdates file while dumping a subdirectory DUMP: the entire dump is aborted can anyone help (6 Replies)
Discussion started by: semosam
6 Replies

5. Infrastructure Monitoring

SNMP log dump

Hello Admin ( and all ) ! Am looking for real time SNMP dump messages, probably some 2 to 3 days old message for efficacy testing in SNMP protocol that is introduced. Since this ours is a real-time site is it possible to get the dumps ? Or is this something like SNMP dumps are not shared... (5 Replies)
Discussion started by: matrixmadhan
5 Replies

6. UNIX for Dummies Questions & Answers

dump command

Hi all, I am using embedded linux with my own RFS. But I want to use the dump command to try and solve some errors, but I don't know in wich package I can find the dump command. I hope someone can help me. With kind regards, Jurrian Dubbeldam (1 Reply)
Discussion started by: Jurrian
1 Replies

7. Red Hat

Dump and restore command usage ??

Hi, I am using RHEL 4.0 I need to take backup of a directory and then restore it to some other location. For taking Backup of final directory, I am using this code: dump -0aj -f /home/vicky/final.dump /home/vicky/final/ Now, I am trying to restore this final.dump to some other... (2 Replies)
Discussion started by: vikas027
2 Replies

8. UNIX for Dummies Questions & Answers

dump command

For ufsdump you type in a "dump level". The man command mentions levels 0-9 and gives examples. Can anyone define what each level refers to? What does a level 0 dump mean? What is a level 9 dump? What are the differences? Thanks in advance:) (1 Reply)
Discussion started by: Patman
1 Replies

9. Filesystems, Disks and Memory

backup NetApp using dump command

I have been trying to backup my NetApp /vol/vol0 data to local tape drive. It is around 68GB. The tape I am using is DLT tape and should be able to handle 70GB data. However, dump always aborted around reaching 57~58GB data. Tape drive is attached on NetApp. 1st try to dump /vol/vol0 to... (2 Replies)
Discussion started by: yellowfish
2 Replies

10. UNIX for Dummies Questions & Answers

Dump Command in Linux

Can anybody tell me please how to use the "dump" command in Linux command. dump -0u /destination /sourcefile or device file. Please correct me. -regards -Iftikhar (1 Reply)
Discussion started by: syedifti
1 Replies
Login or Register to Ask a Question