I do have couple of files in folder. The names of each of the files have a pattern.
Each of the above files have the same pattern of data with 4 columns and have an header for the last 3 columns.
I also have another single file called file1.txt, that has a single column with 19 rows in it.
I would like to get a third file by greping contents from each of the above files in the following manner.
for example, if we take the file B_A17_A17_1T.txt, I would like to grep part of the file name, A17_1T and print it 12 times as the first column. Then print the content of file1.txt as the second column and then print or grep the third column in the file B_A17_A17_1T.txt. I don't need the headers of the file B_A17_A17_1T.txt.
The sample output file will be a tab delimited file:
It would be great if I could do this merging and greping of contents for atleast one file and I could repeat the rest. Is awk best for this?
Thanks vgersh 99. It worked fine. but I would like only part of the file name as the first column. A17_1T. At the present, the awk code will give almost all the file name.
Thanks Chubler_XL. If the file name, B_A17_A17_1T.txt has more character, where do I change the code?
for example instead of B_A17_A17_1T.txt if the file name was Bvtr_A17_A17_1T.txt. Please let me know where to chnage the code. I believe it is in this part of the code
In the awk below I am trying to cp and paste each matching line in f2 to $3 in f1 if $2 of f1 is in the line in f2 somewhere. There will always be a match (usually more then 1) and my actual data is much larger (several hundreds of lines) in both f1 and f2. When the line in f2 is pasted to $3 in... (4 Replies)
hi all,
i had the below script
x=`cat input.txt |wc -1`
awk 'NR>1 && NR<'$x' ' input.txt > output.txt
by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is... (2 Replies)
Hi All,
Please help me in the below issue.I had a file called env.prop.In that i need to change service.url.If i select chocie 2.
it should come as https://dev2.ecif.info53.com:30102/soap/default
30102 port is not fixed .It varies when the file is updated.So i want to keep orginal port in... (3 Replies)
Dear All I have a big set of data which I would like to summerize to have a better sense of it
the problem is like this ...
I have more than 200 files each related to a person which includes different sentences with specific elements (files in a directory)
e.g. mark (one file in the directory)... (9 Replies)
Hi All,
I have 100's of files in the following format. I need to grep or parse out some values from each of the files
{
“tree”: “((A:0.2{0},B:0.09{1}):0.7{2},C:0.5{3}){4};”,
“placements”:
, ], “n”: },
{“p”: ], “n”: }
],
“metadata”:
{“invocation”:
“pplacer -c... (1 Reply)
Hi all - I''m in a little bit of jam - If you can please help
I have a file that has the following content ( please see below)
I need to read the file and then get this result in this format
------------- To put out in this format
name: sophis Total: 22328
name: tca ... (2 Replies)
Hello, this is probably a simple request but I've been toying with it for a while.
I have a large list of devices and commands that were run with a script, now I have lines such as:
a-router-hostname-C#show ver
I want to print everything up to (and excluding) the # and everything after it... (3 Replies)
Hi i am using shell script which perform oracle database query and after that output is redirect to some temporary file.
the output of this file looks like
SQL*Plus: Release 10.2.0.2.0 - Production on Tue Aug 5 16:08:06 2008
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
... (6 Replies)
I am using awk command for greping an value from the file
the file contains ..
file
----------------------------
content-----------
--------
String main = "81507066666";
------------------------------
i am greping the above value using awk command
NumberToReplace=`cat "file" | grep... (1 Reply)
i have a script that checks inside the file and find the start date and end date with time...........
#!/bin/ksh
cd /ednadtu3/u01/pipe/logs
TZ=`date +%Z`+24 ;b=`date +%Y-%m-%d`
echo $b
for i in DBMaint.log
do
echo "Start Time:" >> /ednadtu3/u01/pipe/naveed/Report.txt
cat $i | grep... (3 Replies)