Find header in a text file and prepend it to all lines until another header is found
I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty.
I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the appliance the metrics belong to, there's a header (the name of the asset basically) that is printed just once before all the rest of the text.
What I want to do is find the appliance name and print it before each one of the metrics. See below:
Sample input:
Expected output:
The ending file should, therefore, contain lines with 4 fields each one. Any clues or pointers would be appreciated.
I am trying to get a total number of tapes w/out headers or footers in a ERV file and append it to the file. For some reason I cannot get it to work. Any ideas?
#!/bin/sh
dat=`date +"%b%d_%Y"`
+ date +%b%d_%Y
dat=Nov16_2006
tapemgr="/export/home/legato/tapemgr/rpts"... (1 Reply)
Hi Gurus,
I have a requirement like this and have to create a UX shell scripts. Thanks in advance.
File-in:
------
Header2007-12-012007-11-21
100|xyz|was
101|wsa|qws
......
.......
Output should be:
-------------------
2007-12-01|100|xyz|was
2007-12-01|101|wsa|qws
......
.......... (7 Replies)
say i have these many file in a directory named exam.
1)/exam/newfolder/link.txt.
2)/exam/newfolder1/
and i create a tar say exam.tar
well the problem is,
when i read the tar file i dont find any metadata about the directories,as you cannot create a tar containig empty directories.
on the... (2 Replies)
hi all,
In an mp3 file , data is arranged in sequence of header and data ,how to retrieve data between two headers. Is the data between two headers fixed? because as per theory it says 1152 samples will be there , but dont knw how many bits one sample correspond to?
it would help if any c... (2 Replies)
So, I have a file that has some duplicate lines. The file has a header line that I would like to keep at the top.
I could do this by extracting the header from the file, 'sort -u' the remaining lines, and recombine them. But they are quite big, so if there is a way to do it with a single... (1 Reply)
Hi All,
I need to BCP out a table into a text file along with the table headers. Normal BCP out command only bulk copies the data, and not the headers.
I am using the following command: bcp database1..table1 out file1.dat -c -t\| -b1000 -A8192 -Uuser -Ppassword -efile.dat.err
Regards,... (0 Replies)
Hello All,
I have a file in the following format. I want to extract the date(020090930, 020090929) in the string "STPAGE020090930" and "STPAGE020090929" and prefix it to all lines below them. The output must be put into a new file.
STPAGE020090930
xyzz aalc... (3 Replies)
Friends,
I need help with the following in UNIX.
Merge all csv files in one folder considering only 1 header row and ignoring header of all other files.
FYI - All files are in same format and contains same headers.
Thank you (4 Replies)
I would like to print the output beginning with a header from a seperate file like this:
awk 'BEGIN{FS="_";print ((getline < "header.txt")>0)} { if (! ($0 ~ /EL/ ) print }" input.txtWhat am i doing wrong? (4 Replies)
Hi
I have in put file A.txt
ABCDE1 JFHFJFJF3 1 1 SC1 12/10
ABCDE2 JFHFJFJF5 1 1 SC1 12/10
ABCDE3 JFHFJFJF5 1 1 SC1 12/10
ABCDE4 JFHFJFJF6 1 1 SC1 12/10
I want output in .csv with header:
Name SUb_N x y No Board
ABCDE1 JFHFJFJF3 1 1 SC1 12/10
ABCDE2 JFHFJFJF5 1 1 SC1... (7 Replies)
Discussion started by: pareshkp
7 Replies
LEARN ABOUT MOJAVE
findrule
FINDRULE(1) User Contributed Perl Documentation FINDRULE(1)NAME
findrule - command line wrapper to File::Find::Rule
USAGE
findrule [path...] [expression]
DESCRIPTION
"findrule" mostly borrows the interface from GNU find(1) to provide a command-line interface onto the File::Find::Rule heirarchy of
modules.
The syntax for expressions is the rule name, preceded by a dash, followed by an optional argument. If the argument is an opening
parenthesis it is taken as a list of arguments, terminated by a closing parenthesis.
Some examples:
find -file -name ( foo bar )
files named "foo" or "bar", below the current directory.
find -file -name foo -bar
files named "foo", that have pubs (for this is what our ficticious "bar" clause specifies), below the current directory.
find -file -name ( -bar )
files named "-bar", below the current directory. In this case if we'd have omitted the parenthesis it would have parsed as a call to name
with no arguments, followed by a call to -bar.
Supported switches
I'm very slack. Please consult the File::Find::Rule manpage for now, and prepend - to the commands that you want.
Extra bonus switches
findrule automatically loads all of your installed File::Find::Rule::* extension modules, so check the documentation to see what those
would be.
AUTHOR
Richard Clamp <richardc@unixbeard.net> from a suggestion by Tatsuhiko Miyagawa
COPYRIGHT
Copyright (C) 2002 Richard Clamp. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
File::Find::Rule
perl v5.18.2 2011-09-19 FINDRULE(1)