Sponsored Content
Top Forums Shell Programming and Scripting How to adding the filename into file contents Post 89165 by missutoomuch on Friday 11th of November 2005 03:39:09 AM
Old 11-11-2005
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..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

adding contents of a variable to a command

hi all, i'm new to shell scripting, so i'm not sure how to work this. Is it possible to read in the contents of a variable and add it to a command? for example: ------------------------ #!/bin/sh set example = -dfr rm ${example} ------------------------ when i run the script, i want... (2 Replies)
Discussion started by: gammarays
2 Replies

2. Shell Programming and Scripting

Adding filename into file content

Dear Experts, Please help to teach me how to add the filename into the file content. Actually the file name are EVENTS-20050912. ***************New output that I want*************** EVENTS-20050912 03:33:37 ALARM: BTSSPAN-277-1 30-18013 EVENTS-20050912 12:10:28 ALARM: BTSSPAN-297-2... (1 Reply)
Discussion started by: missutoomuch
1 Replies

3. UNIX for Dummies Questions & Answers

adding contents of file

for example i have a file which contains data like: 123 222 325 142 can anyone help me write a script that adds them? let's say that "total" is the filename... (4 Replies)
Discussion started by: dakid
4 Replies

4. Shell Programming and Scripting

Grabing Date from filename and adding to the end of each line in the file.

Hi, I have 24 .dat files something like below. The file name starts with “abc” followed by two digit month and two digit year. Is there a way to grab the month and year from each filename and append it to the end of each line. Once this is done I want to combine all the files into file... (1 Reply)
Discussion started by: rkumar28
1 Replies

5. Shell Programming and Scripting

Passing filename as parameter and displaying the file contents

Hi All, Its extremely urgent regarding the following requirement. I have created few files in a directory. I have write a program in shell scripting such that it prompts for the filename . once the filename is entered,it should print the contents of the file. Can anyone help with... (7 Replies)
Discussion started by: radhi2424
7 Replies

6. Shell Programming and Scripting

Help with adding leading zeros to a filename

Hi i need help in adding leading zero to filenames e.g file name in my folder are 1_234sd.txt 23_234sd.txt the output i need is 001_234sd.txt 023_234sd.txt can i do this shell scripting please help (2 Replies)
Discussion started by: rsmpk
2 Replies

7. Shell Programming and Scripting

Adding filename to each line of the file

Hi, I am a relative new bee in scripting. I need to develop a script such that the code would iterate through each file in a source directory and append every line of the file with '|' and the corresponding file filename. eg INPUT file IF927_1.dat - H|abc... (4 Replies)
Discussion started by: scripting_newbe
4 Replies

8. UNIX for Dummies Questions & Answers

Adding Filename as column using sed

Hi , Can any one please tell me, how can we add the file name as column using sed. right now we are using the below awk command for adding the file name as column but when we are calling this script from datastage it is deleting the file data..very weird raised a support ticket with datastage.... (2 Replies)
Discussion started by: mora
2 Replies

9. Shell Programming and Scripting

Adding filename and line number from multiple files to final file

Hi all, I have 20 files (file001.txt upto file020.txt) and I want to read them from 3rd line upto end of file (line 1002). But in the final file they should appear to start from line 1. I need following kind of output in a single file: Filename Line number 2ndcolumn 4thcolumn I... (14 Replies)
Discussion started by: bioinfo
14 Replies

10. Shell Programming and Scripting

awk to place specific contents filename within text file

I am trying to use awk to place the contens of a filename in $1 and $2 followed by the data in the text file. Basically, put the filename within the text file. There are over 1000 files in the directory and as of now each file is saved with a unique name but it is not within the file. Thank you... (10 Replies)
Discussion started by: cmccabe
10 Replies
ALARM(2)						     Linux Programmer's Manual							  ALARM(2)

NAME
alarm - set an alarm clock for delivery of a signal SYNOPSIS
#include <unistd.h> unsigned int alarm(unsigned int seconds); DESCRIPTION
alarm() arranges for a SIGALRM signal to be delivered to the calling process in seconds seconds. If seconds is zero, no new alarm() is scheduled. In any event any previously set alarm() is canceled. RETURN VALUE
alarm() returns the number of seconds remaining until any previously scheduled alarm was due to be delivered, or zero if there was no pre- viously scheduled alarm. CONFORMING TO
SVr4, POSIX.1-2001, 4.3BSD. NOTES
alarm() and setitimer(2) share the same timer; calls to one will interfere with use of the other. sleep(3) may be implemented using SIGALRM; mixing calls to alarm() and sleep(3) is a bad idea. Scheduling delays can, as ever, cause the execution of the process to be delayed by an arbitrary amount of time. SEE ALSO
gettimeofday(2), pause(2), select(2), setitimer(2), sigaction(2), signal(2), sleep(3), time(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2008-06-12 ALARM(2)
All times are GMT -4. The time now is 06:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy