The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
change the filename by adding up 1 each time, tricky one netbanker Shell Programming and Scripting 5 03-07-2008 04:45 PM
Grabing Date from filename and adding to the end of each line in the file. rkumar28 Shell Programming and Scripting 1 05-01-2007 08:25 PM
adding contents of file dakid UNIX for Dummies Questions & Answers 4 10-20-2006 02:24 PM
Adding filename into file content missutoomuch Shell Programming and Scripting 1 11-11-2005 04:02 PM
adding contents of a variable to a command gammarays Shell Programming and Scripting 2 02-08-2005 01:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-11-2005
missutoomuch missutoomuch is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 4
How to adding the filename into file contents

Dear Experts,

Please help to teach me how to add the filename into the file content so that i can get the output below:-

Actually the file name

***************New output that I want***************
=====2005-11-12=====
EVENTS-20050912 03:33:37 ALARM: BTSSPAN-277-1 30-18013
EVENTS-20050912 12:10:28 ALARM: BTSSPAN-297-2 30-18013
EVENTS-20050912 20:40:05 ALARM: BTSSPAN-297-1 30-18013
EVENTS-20050912 23:55:27 ALARM: BTSSPAN-277-1 30-18013

=====2005-11-13=====
EVENTS-20050913 04:32:42 ALARM: BTSSPAN-193-1 30-18013
EVENTS-20050913 05:40:53 ALARM: BTSSPAN-526-1 30-18013
EVENTS-20050913 09:32:16 ALARM: BTSSPAN-297-2 30-18013
EVENTS-20050913 22:33:07 ALARM: BTSSPAN-297-1 30-18013

**********************************************************

***My existing script but cannot add file name into the content ***
bavsmap1:/data/EVENTS $ for i in EVENTS-20050912 EVENTS-20050913
> do
> echo "=====2005-11-$i====="
> zcat $i.tar.Z|plgrep "30-18013"|time_stamp -i|tail +3|awk '{print $1, $2, $3, $4}'
> done
=====2005-11-12=====
03:33:37 ALARM: BTSSPAN-277-1 30-18013
12:10:28 ALARM: BTSSPAN-297-2 30-18013
20:40:05 ALARM: BTSSPAN-297-1 30-18013
23:55:27 ALARM: BTSSPAN-277-1 30-18013
=====2005-11-13=====
04:32:42 ALARM: BTSSPAN-193-1 30-18013
05:40:53 ALARM: BTSSPAN-526-1 30-18013
09:32:16 ALARM: BTSSPAN-297-2 30-18013
22:33:07 ALARM: BTSSPAN-297-1 30-18013

Last edited by missutoomuch; 11-11-2005 at 05:23 AM..
  #2 (permalink)  
Old 11-11-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
This is the new output.

=====2005-11-12=====
2005-11-12 03:33:37 ALARM: BTSSPAN-277-1 30-18013
2005-11-12 12:10:28 ALARM: BTSSPAN-297-2 30-18013
2005-11-12 20:40:05 ALARM: BTSSPAN-297-1 30-18013
2005-11-12 23:55:27 ALARM: BTSSPAN-277-1 30-18013

=====2005-11-13=====
2005-11-13 04:32:42 ALARM: BTSSPAN-193-1 30-18013
2005-11-13 05:40:53 ALARM: BTSSPAN-526-1 30-18013
2005-11-13 09:32:16 ALARM: BTSSPAN-297-2 30-18013
2005-11-13 22:33:07 ALARM: BTSSPAN-297-1 30-18013

This is what seems like the original input.

=====2005-11-12=====
03:33:37 ALARM: BTSSPAN-277-1 30-18013
12:10:28 ALARM: BTSSPAN-297-2 30-18013
20:40:05 ALARM: BTSSPAN-297-1 30-18013
23:55:27 ALARM: BTSSPAN-277-1 30-18013
=====2005-11-13=====
04:32:42 ALARM: BTSSPAN-193-1 30-18013
05:40:53 ALARM: BTSSPAN-526-1 30-18013
09:32:16 ALARM: BTSSPAN-297-2 30-18013
22:33:07 ALARM: BTSSPAN-297-1 30-18013

The only difference in both the above exhibits is the introduction of timestamp. There is no filename in the preferred output you have given.
  #3 (permalink)  
Old 11-11-2005
missutoomuch missutoomuch is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 4
Sorry I make myself not clear... There are 2 files names which are "EVENTS-20050912" "EVENTS-20050913".
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0