I too have a similar requirement. I was reffering to your code
Code:
awk '
BEGIN { FS=OFS=";" }
NR==FNR {
# 1st file: build hd[]
for (i=1; i<=NF; i++) { hd[$i] }
next
}
FNR==1 {
# header of 2nd file: if in hd[] note that column in col[]
for (i=1; i<=NF; i++) {
if ($i in hd) { col[i] } else { print "Column " i ": " $i > "mismatch.txt" }
}
}
{
# print the columns that are in col[]
sep=""
for (i=1; i<=NF; i++) {
if (i in col) { printf "%s%s", sep, $i; sep=OFS }
}
print ""
}
' declare.txt feed.txt
Where in I need to remove the new columns from a daily input data file if the same is not added in the database and report the new columns to the user.
I tried the above code to generate an output file (by using the similar sample files created by me). by slightly modifying the last line of the above code to generate the output file like
' declare.txt feed.txt > feed2.txt
Every thing works fine, it is creating a new file. If the columns are added, it is creating a "Mismatch.txt" file and if no new columns are added then it is skipping the creation of "Mismatch.txt". And in both the scenarios it is creating feed2.txt.
The code is even removing the new columns along with it's values.
But what I noticed is file size of feed2.txt is getting changed even when there is no new column added in the feed.txt file (sample file).
I have European characters like Á, Ä, Ç, Ë, Ê, É, ß, Ô, Ü in my input file "feed.txt". And I think those characters are getting messed up with some junk values when I run the script. They are not proplery shown when I open the input file in VI editor.
My question is, in the database we have the settings to be changed like charset and collatiion for recogninsing the international characters.
Is there such thing on Linux or UNIX for identifying and displaying the international characters?
I am to happy find a similar requirement with a solution which matches with my requirement. But I am stuck because of the filesize difference.
Please help me.
Merlin Joseph
Last edited by Franklin52; 09-14-2014 at 12:09 PM..
Reason: Please use regular code tags instead of inline code tags for multiple lines
Hi all,
I want to create column names in a flat file and then load the data through some other application. For example, I have a file with emp.txt and I need column names as eno,ename,sal in the first line. The delimiter here is comma and record delimiter is end of line or unix new line. Could... (1 Reply)
Hi,
I want to write a script which will compare the 1st column of both the files and will give the difference.
e.g:-
my 1st file contains:
89 /usr
52 /usr/local
36 /tmp
92 /opt
96 /home
27 /etc/opt/EMCom
1 ... (3 Replies)
Hi All,
i have a file that is tab delimited. i need help to find the rows which are having same price based on the site code but some times, there are difference so i need to find only the records which are different in all site code.
Dept Sec Barcode 10001 10002 10003 10004... (1 Reply)
Hi All,
I have a file example.csv which looks like this
GrpID,TargetID,Signal,Avg_Num
CSCH74_1_1,2007,61,256
CSCH74_1_1,212007,647,679
CSCH74_1_1,12007,3,32
CSCH74_1_1,207,299,777
I want the output as
GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num
CSCH74_1_1,2007,61,256... (4 Replies)
Hi All,
I have a file example.csv which looks like this
GrpID,TargetID,Signal,Avg_Num
CSCH74_1_1,2007,61,256
CSCH74_1_1,212007,647,679
CSCH74_1_1,12007,3,32
CSCH74_1_1,207,299,777
I want the output as
GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num
CSCH74_1_1,2007,61,256... (1 Reply)
Hi , i am newbie to shell scripting and am trying to do the below job,
A shell script to be run with a command like
sh Compare.ksh file1.txt file2.txt 1 2 > file3.txt
1 2-are the key columns
Consider the delimiter would be Tab or comma
File 1:
SK TEST NAME MATHS PHYSICS
21 1... (1 Reply)
Hi , i am newbie to shell scripting and am trying to do the below job,
A shell script to be run with a command like
sh Compare.ksh file1.txt file2.txt 1 2 > file3.txt
1 2-are the key columns
Consider the delimiter would be Tab or comma
File 1:
SK TEST NAME MATHS PHYSICS
21 1 AAA... (1 Reply)
In a bash shell, I have to prefix a variable to two .CSV files File1.CSV and File2.CSV. One of the files has a header and the other one is with no header in the below format:
"value11","value12","value13","value14","value15","value16"
"value21","value22","value23","value24","value25","value26"... (7 Replies)
Discussion started by: dhruuv369
7 Replies
LEARN ABOUT ULTRIX
makedbm
makedbm(8yp)makedbm(8yp)Name
makedbm - make a yellow pages dbm file
Syntax
makedbm [ -i yp_input_file ] [ -o yp_output_name ] [ -d yp_domain_name ] [ -m yp_master_name ] infile outfile
makedbm [ -u dbmfilename ]
Description
The command takes the file specified by the argument infile and converts it to a pair of files in format, namely and Each line of the input
file is converted to a single record. All characters up to the first tab or space form the key, and the rest of the line is defined as the
key's associated data. If a line ends with a backslash (), the data for that record is continued onto the next line. It is left for the
clients of the yellow pages to interpret the number sign (#); does not treat it as a comment character. The infile parameter can be a
hyphen (-), in which case reads the standard input.
The command is meant to be used in generating files for the yellow pages service. The command generates a special entry with the key
yp_last_modified, which is the date of infile.
Options-i Create a special entry with the key yp_input_file.
-o Create a special entry with the key yp_output_name.
-d Create a special entry with the key yp_domain_name.
-m Create a special entry with the key yp_master_name. If no master host name is specified, yp_master_name will be set to the local
host name.
-u Undo a file. That is, print out a file one entry per line, with a single space separating keys from values.
Examples
The following example shows how a combination of commands can be used to make the yellow pages files and from the file. The percent sign
(%) signifies the system prompt.
% awk 'BEGIN { FS = ":"; OFS = ""; }
{ print $1, $0 }' /etc/passwd > ptmp
% makedbm ptmp passwd.byname
% rm ptmp
The command creates the file ptmp which is in a form usable by The command uses the ptmp file to create the yellow pages dbm files and The
command removes the ptmp file.
See Alsoyppasswd(1yp), dbm(3x), ypmake(8yp)makedbm(8yp)