cmp 2 variables


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers cmp 2 variables
# 1  
Old 08-18-2008
cmp 2 variables

Hi I have two variables contining a set of near identical lines, i'd like to list the lines that differ? Prefereably i'd like not to save the variables into a file first.

i.e
var1
tag:val1
tag:val2
tag:val3

var2
tag:val1
tag:val4
tag:val3

i'd like the result to print out something like tag:val2 <> tag:val4.

I was thinking of using cmp to get the line numbers and then sed/awk to get the output.

I ideas on the 'best' solution to this?Smilie

thanks in advance.
# 2  
Old 08-18-2008
are those variable present in same file??
# 3  
Old 08-18-2008
Hi,

The variables are created from a command substitution which runs an application to describe a table structure.

What i want to do is compare the output from this application to compare the structure of two tables. The main aim is to describe the differences between the tables.

The variable thing is a bit misleading i suppose because I can just create temp files in /usr/tmp and then delete them? Is that the right place to put temp files?

Thinking about it it a bit more it would be useful to describe the new table as well as showing the differences.

so if i had two files
file1 - new table
colname:col1
coltype:col1
colsize:col1

colname:col2
coltype:col2
colsize:col2

and file2- old table
colname:col1
coltype:col1
colsize:col1

colname:col4
coltype:col4
colsize:col4

i'd like the result to be something like this:
col property file1 file2
colname col1 col1
coltype col1 col1
colsize col1 col1

colname col2 -
coltype col2 -
colsize col2 -

colname - col4
colname - col4
colsize - col4

Does this make any sense? I think it's probably an awk script?

sorry for changing the tack of the question.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

2. Shell Programming and Scripting

Syntax Error while using CMP function

Hi All, I am getting a syntax error message while trying to compare 2 files using the compare function (LINUX) command substitution: line 79: syntax error near unexpected token `(' command substitution: line 79: `cmp -s <(tr , \n < $COMMON_TMP/nt_per_gs.done | sort) <(tr , \n <... (5 Replies)
Discussion started by: dsfreddie
5 Replies

3. Shell Programming and Scripting

How to compare files in two folders using cmp?

i recently copied 400GB of data from a NTFS drive to a ext4 drive. I want to verify that the data is 100% identical to the original. I wanted to use cmp but it only does two files. The directory that was copied contains many subdirectories and all sorts of files (not just text). So I guess... (5 Replies)
Discussion started by: fuzzylogic25
5 Replies

4. Solaris

cmp file

Dear all, for i in <List of Filename> FILENAME=`echo $i` do cp -p $FILENAME /temp /bin/cmp $FILENAME /temp/$FILENAME done I am planning to do something like this on a daily basis, so i want to ask that, if the comparison on the files encounter error, ... (2 Replies)
Discussion started by: beginningDBA
2 Replies

5. Shell Programming and Scripting

Issue in comparing (cmp) two files

Hi All, I have to compare set of files so I created a case statement with the option to give more than one file to compare. The Problem now i am facing is, if I compare the files directly, from prompt or just using the script only for a particular file then It's saying No difference, but If I... (4 Replies)
Discussion started by: Sudhar
4 Replies

6. Shell Programming and Scripting

date cmp

Please don't count this as a similar post.....I got the ftp part working....I am stuck how to find the files between two dates. I have 5 files filename.20090505.txt filename.20090504.txt filename.20090503.txt filename.20090502.txt filename.20090501.txt My load date is 20090501 and run date... (5 Replies)
Discussion started by: RubinPat
5 Replies

7. Shell Programming and Scripting

CMP two files with slight difference and return code

I am comparing two files which are identical except for the timestamp which is incorporated within the otherwise same 372 bytes. I am using the command: cmp -s $Todays_file $Yesterdays_file -i 372 When I run the command without the -i 372 it shows the difference i.e. the timestamp.... (5 Replies)
Discussion started by: gugs
5 Replies

8. Programming

How to convert byteArray variables to HexaString variables for Linux?

Hello everybody, I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Discussion started by: ritesh_163
2 Replies

9. Shell Programming and Scripting

cmp, diff need options

Hi, I am using diff filename1 filename2, as these files are of huge size,I want to know the count(n) no. of different records to be displayed on the terminal. I do not want the contents of file i mean different lines to be displayed. Cheers Kunal. (0 Replies)
Discussion started by: niceboykunal123
0 Replies
Login or Register to Ask a Question