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(3)						   BSD Library Functions Manual 						  ALARM(3)

NAME
alarm -- set signal timer alarm LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> unsigned alarm(unsigned seconds); DESCRIPTION
This interface is made obsolete by setitimer(2). The alarm() function sets a timer to deliver the signal SIGALRM to the calling process after the specified number of seconds. If an alarm has already been set with alarm() but has not been delivered, another call to alarm() will supersede the prior call. The request alarm(0) voids the current alarm and the signal SIGALRM will not be delivered. Due to setitimer(2) restriction the maximum number of seconds allowed is 100000000. RETURN VALUES
The return value of alarm() is the amount of time left on the timer from a previous call to alarm(). If no alarm is currently set, the return value is 0. SEE ALSO
setitimer(2), sigaction(2), sigpause(2), sigvec(2), signal(3), sleep(3), ualarm(3), usleep(3) HISTORY
An alarm() function appeared in Version 7 AT&T UNIX. BSD
April 19, 1994 BSD
All times are GMT -4. The time now is 01:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy