Comapring files charecter by charecter using AWK/Shell Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comapring files charecter by charecter using AWK/Shell Script
# 1  
Old 09-12-2007
Question Comapring files charecter by charecter using AWK/Shell Script

Hi...
I have a requrement to compare two files.
for e.g.

File 1
2007/08/19 09:48:10 DH-032 $APTA1: Device AATD8029
2007/08/19 09:48:10 DH-045 $APTA1: Device AATD8029
2007/08/19 09:48:10 DH-043 $APTA1: Device AATD8029

File 2
2007-08-19 09:48:10 DH-032 $APTA1: Device AATD8029
2007-08-19 09:48:10 DH-043 $APTA1: Device AATD8029
2007-08-19 09:48:10 DH-045 $APTA1: Device AATD8029

I need to check the format, column Positioning...etc
in file1 the date is 2007/08/19
in file 2 it is 2007-08-19

In file 2 one extra space occured between column 2 and column 3 ...

I have to identify the differences and i need the postion of that difference.

Please any one help me out .

Thanks in Advance
# 2  
Old 09-12-2007
With diff you get line positions:

Code:
$ cat file1
2007/08/19 09:48:10 DH-032 $APTA1: Device AATD8029
2007/08/19 09:48:10 DH-045 $APTA1: Device AATD8029
2007/08/19 09:48:10 DH-043 $APTA1: Device AATD8029 
$ cat file2
2007-08-19 09:48:10  DH-032 $APTA1: Device AATD8029
2007-08-19 09:48:10  DH-043 $APTA1: Device AATD8029
2007-08-19 09:48:10  DH-045 $APTA1: Device AATD8029 
$ diff -b <(tr '/' '-'<file1) file2
2d1
< 2007-08-19 09:48:10 DH-045 $APTA1: Device AATD8029
3a3
> 2007-08-19 09:48:10  DH-045 $APTA1: Device AATD8029

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Simple question about charecter count

Hi, I have collection of letters in a column such as: AA5678 AA9873434 .. .. I am trying to find the number of charecters in each. "echo "AA5678"|wc -c 7----------------> why does it give 7 instead of 6? (6 Replies)
Discussion started by: kvosu
6 Replies

2. Shell Programming and Scripting

If condition fails for special charecter

I have a sample server name listed in variable as below: var="server-13" I need to check if the 7th character on $var is number 1 whichenv=`echo "$var"| head -c 7 | tail -c 1` if ]; then echo "9 found" else echo "9 Not Found" fi Output: This works... (3 Replies)
Discussion started by: mohtashims
3 Replies

3. Shell Programming and Scripting

Need special charecter in email body

I have a unix shell script generate.sh that writes to a file hello.txt using redirect. For example:echo " Today's report shows progress by: " > hello.txt This hello.txt is then send as an email body to the recipients. My requirement is to have this special characters(up arrow and down arrow... (6 Replies)
Discussion started by: mohtashims
6 Replies

4. UNIX for Dummies Questions & Answers

cutting columns if delimiter has more than one charecter (|^)

Hi All, I am having a file with the delimiter '|^'. File name:test_dlim.csv I want to cut the first field of this using awk command. I tried with the help of the following link:... (2 Replies)
Discussion started by: boopathyvasagam
2 Replies

5. Shell Programming and Scripting

to delete charecter in a line

Hi, Using perl, how can I delete a charecter (specify the position number), in a line which starts with "GETR P" and another line starting with "GET P:=". This needs tro be done for many charecters in a line Thanks Vijayalakshmi (2 Replies)
Discussion started by: abc_81
2 Replies

6. Shell Programming and Scripting

Delete last charecter of each line.

Hi, I have file which is having the following content. 11082202^M 10951265^M 11482003^M 12820986^M 11309561^M 11092815^M 11103308^M 13024722^M 11343958^M 11280355^M 7516723^M i want to delete the last charecter "^M" from all the line and redirect to other line. Please help... (1 Reply)
Discussion started by: shivanete
1 Replies

7. UNIX for Dummies Questions & Answers

charecter or number

Hi Friends, How to check a variable value is either charecter or number? With Regards / Ganapati (1 Reply)
Discussion started by: ganapati
1 Replies

8. Shell Programming and Scripting

find charecter from its ascii value.

how could find charecter from its ascii value. please suggest me any code for that. thannks in advance. (2 Replies)
Discussion started by: rinku
2 Replies

9. Shell Programming and Scripting

cut First charecter in any string

I wannt to cut first char of any string. str=A2465443 out put will be. str1=A str2=2465443. I tried str2=${?%srt} str1=${str#$str2} it is not working. (6 Replies)
Discussion started by: rinku
6 Replies

10. UNIX for Dummies Questions & Answers

cutting columns if delimiter has more than one charecter

Hi, My file looks like abc$%sdfhs$%sdf$%sdfaf$% here as seen delimiter is $%...now how cas i take out second field as cut command expect delimiter as single charecter only.....is there is any other way thanks and regards mahabunta (9 Replies)
Discussion started by: mahabunta
9 Replies
Login or Register to Ask a Question