Sponsored Content
Full Discussion: Adding two files
Top Forums Shell Programming and Scripting Adding two files Post 302950702 by anshu ranjan on Tuesday 28th of July 2015 05:36:00 AM
Old 07-28-2015
Adding two files

I have a file which entry is below
cat file1

Code:
user1
user2
user3

another file, which entry is below
cat file2
Code:
Proj1 Fin
Proj2 Marketing

I want O/P as below
Code:
Delete User Profile "user1" FROM Proj1 Fin
Delete User Profile "user1" FROM Proj2 Marketing
Delete User Profile "user2" FROM Proj1 Fin
Delete User Profile "user2" FROM Proj2 Marketing
Delete User Profile "user3" FROM Proj1 Fin
Delete User Profile "user3" FROM Proj2 Marketing

I wrote a small script as below but i am not getting require O/P. script and Output of script is below.
script
Code:
#!/bin/bash
for i in `cat file1`
do
for j in `cat file2`
do
echo "Delete User Profile \""$i"\" FROM "$j"" >> OP1
done
done

O/P of script
Code:
Delete User Profile "user1" FROM Proj1
Delete User Profile "user1" FROM Fin
Delete User Profile "user1" FROM Proj2
Delete User Profile "user1" FROM Marketing
Delete User Profile "user2" FROM Proj1
Delete User Profile "user2" FROM Fin
Delete User Profile "user2" FROM Proj2
Delete User Profile "user2" FROM Marketing
Delete User Profile "user3" FROM Proj1
Delete User Profile "user3" FROM Fin
Delete User Profile "user3" FROM Proj2
Delete User Profile "user3" FROM Marketing

Can anyone please help me what wrong I am doing. I tried to use awk but it also not working as per requirement.

Last edited by rbatte1; 07-28-2015 at 06:55 AM.. Reason: Changed ICODE tags to CODE tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

adding two files

Dear Experts, I am facing some problem. I have two files, every field is separated by comma "," separator. And the value is in numeric FILEA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 FILE B ... (7 Replies)
Discussion started by: shary
7 Replies

2. Shell Programming and Scripting

awk adding columns from different files

Hi, I have two files and I need to add column 3 of file1 to column 3 of file 2 > file3 I also need to repeat for column 4. Thanks (1 Reply)
Discussion started by: dsstamps
1 Replies

3. Shell Programming and Scripting

Adding columns of two files

Hello everyone, I have two files containing 6 columns and thousands of rows. I want to add them (i.e. first column of first file + first column of second file and so on) and print the output in a third file. Can you please help me. Thanks a lot (7 Replies)
Discussion started by: chandra321
7 Replies

4. Shell Programming and Scripting

renaming files or adding a name in the beginning of all files in a folder

Hi All I have a folder that contains hundreds of file with a names 3.msa 4.msa 21.msa 6.msa 345.msa 456.msa 98.msa ... ... ... I need rename each of this file by adding "core_" in the begiining of each file such as core_3.msa core_4.msa core_21.msa (4 Replies)
Discussion started by: Lucky Ali
4 Replies

5. Shell Programming and Scripting

Adding the trailers in two files

I have two files File1 has trailer as below TR|2|120 File2 has trailer as below TR|1|100 it should add both the fields from trailer of file 1 and 2....so that file2 has a trailer as TR|3|220 (3 Replies)
Discussion started by: Deepak62828r
3 Replies

6. UNIX for Dummies Questions & Answers

Adding new columns to txt files

Dear all, I have a question. I have a txt.file as below. i want to add 3 more columns: column3=conlum 2*column2; column4=(1-column2)*(1-column2); column5=1-column3-column4. Do you know how to do it? Thanks a lot! file: column1 column2 a 1 b 20 c 30 d 3 ... (2 Replies)
Discussion started by: forevertl
2 Replies

7. Shell Programming and Scripting

Adding Multiple Files via Columns

I have a number of files with multiple rows that I need to add together. Let say I have 10 files: Each file has a great number of rows and columns. I need to add these files together the following way. In other words, If, for example, file A occupies Columns 1 to 19, I want to add file B... (7 Replies)
Discussion started by: Ernst
7 Replies

8. Shell Programming and Scripting

Help with joining files and adding headers to files

Hi, I have about 20 tab delimited text files that have non sequential numbering such as: UCD2.summary.txt UCD45.summary.txt UCD56.summery.txt The first column of each file has the same number of lines and content. The next 2 column have data points: i.e UCD2.summary.txt: a 8.9 ... (8 Replies)
Discussion started by: rrdavis
8 Replies

9. Red Hat

RPM package, conditional adding files in "%files" section

Hello, Is it possible to specify a list of files to be included in an RPM package (section "% files") according to some condtions. For example, if a particular condition is true, do not include the file "X". If not include it. Thank you for your help. Regards (1 Reply)
Discussion started by: louzorios
1 Replies

10. UNIX for Dummies Questions & Answers

Adding unzipped files to a Zip

Hey all, I have a zip file which I received, and I need to replace one of the files inside of it. I tried the obvious solution of unzipping the zip, replacing the file, and rezipping, but the following happened: Original Zip Size: 79MB Unzipped Size 80MB New Zip: 36MB When I feed the... (2 Replies)
Discussion started by: DeanLeitersdorf
2 Replies
DBI::ProfileDumper(3)					User Contributed Perl Documentation				     DBI::ProfileDumper(3)

NAME
DBI::ProfileDumper - profile DBI usage and output data to a file SYNOPSIS
To profile an existing program using DBI::ProfileDumper, set the DBI_PROFILE environment variable and run your program as usual. For exam- ple, using bash: DBI_PROFILE=DBI::ProfileDumper program.pl Then analyze the generated file (dbi.prof) with dbiprof: dbiprof You can also activate DBI::ProfileDumper from within your code: use DBI; # profile with default path (2) and output file (dbi.prof) $dbh->{Profile} = "DBI::ProfileDumper"; # same thing, spelled out $dbh->{Profile} = "2/DBI::ProfileDumper/File/dbi.prof"; # another way to say it use DBI::Profile qw(DBIprofile_Statement); $dbh->{Profile} = DBI::ProfileDumper->new( { Path => [ DBIprofile_Statement ] File => 'dbi.prof' }); # using a custom path $dbh->{Profile} = DBI::ProfileDumper->new({ Path => [ "foo", "bar" ], File => 'dbi.prof' }); DESCRIPTION
DBI::ProfileDumper is a subclass of DBI::Profile which dumps profile data to disk instead of printing a summary to your screen. You can then use dbiprof to analyze the data in a number of interesting ways, or you can roll your own analysis using DBI::ProfileData. NOTE: For Apache/mod_perl applications, use DBI::ProfileDumper::Apache. USAGE
One way to use this module is just to enable it in your $dbh: $dbh->{Profile} = "DBI::ProfileDumper"; This will write out profile data by statement into a file called dbi.prof. If you want to modify either of these properties, you can con- struct the DBI::ProfileDumper object yourself: use DBI::Profile qw(DBIprofile_Statement); $dbh->{Profile} = DBI::ProfileDumper->new( { Path => [ DBIprofile_Statement ] File => 'dbi.prof' }); The "Path" option takes the same values as in DBI::Profile. The "File" option gives the name of the file where results will be collected. If it already exists it will be overwritten. You can also activate this module by setting the DBI_PROFILE environment variable: $ENV{DBI_PROFILE} = "DBI::ProfileDumper"; This will cause all DBI handles to share the same profiling object. METHODS
The following methods are available to be called using the profile object. You can get access to the profile object from the Profile key in any DBI handle: my $profile = $dbh->{Profile}; $profile->flush_to_disk() Flushes all collected profile data to disk and empties the Data hash. This method may be called multiple times during a program run. $profile->empty() Clears the Data hash without writing to disk. DATA FORMAT
The data format written by DBI::ProfileDumper starts with a header containing the version number of the module used to generate it. Then a block of variable declarations describes the profile. After two newlines, the profile data forms the body of the file. For example: DBI::ProfileDumper 1.0 Path = [ DBIprofile_Statement, DBIprofile_MethodName ] Program = t/42profile_data.t + 1 SELECT name FROM users WHERE id = ? + 2 prepare = 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 + 2 execute 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 + 2 fetchrow_hashref = 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 + 1 UPDATE users SET name = ? WHERE id = ? + 2 prepare = 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 + 2 execute = 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 The lines beginning with "+" signs signify keys. The number after the "+" sign shows the nesting level of the key. Lines beginning with "=" are the actual profile data, in the same order as in DBI::Profile. Note that the same path may be present multiple times in the data file since "format()" may be called more than once. When read by DBI::ProfileData the data points will be merged to produce a single data set for each distinct path. The key strings are transformed in three ways. First, all backslashes are doubled. Then all newlines and carriage-returns are transformed into " " and " " respectively. Finally, any NULL bytes ("") are entirely removed. When DBI::ProfileData reads the file the first two transformations will be reversed, but NULL bytes will not be restored. AUTHOR
Sam Tregar <sam@tregar.com> COPYRIGHT AND LICENSE
Copyright (C) 2002 Sam Tregar This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. perl v5.8.0 2002-12-01 DBI::ProfileDumper(3)
All times are GMT -4. The time now is 05:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy