| | |
Hi! Reading from a file takes lot of time?
![]() |
•
•
Join Date: Sep 2008
Posts: 2
Reputation:
Solved Threads: 0
Hello experts ! I'm a newbiee to this shell scripting! I try to write a "diff" kinda script which compares two text files and echos the differences. The only different is, my script doesn't care about the character "x" in the first file , being replaced with any other character in the second file. I wrote a script which was perfect(logically correct) with smaller files, takes a hell a lot of time to read 500kb files which I 'm supposed to play with for my work.
Those files contain all digital logic outputs dumped by an IP tool ( zeros(0) ,ones(1) and Don't care terms(x)). I hope now you may understand the reason why I'm trying to do this. Any help?
My code:
Those files contain all digital logic outputs dumped by an IP tool ( zeros(0) ,ones(1) and Don't care terms(x)). I hope now you may understand the reason why I'm trying to do this. Any help?
My code:
Shell Scripting Syntax (Toggle Plain Text)
#!/bin/bash dumpraw=bavan1 //file1 dumpafterpack=bavan2 //file2 index1=0 index2=0 cat $dumpraw > $dumpraw.tmp // just make temp file of file 1 cat $dumpafterpack > $dumpafterpack.tmp // temp file of file2 while read line1 ; do MYARRAY1[$index1]="$line1" index1=$(($index1+1)) done < $dumpraw.tmp rm -rf $dumpraw.tmp while read line2 ; do MYARRAY2[$index2]="$line2" index2=$(($index2+1)) done < $dumpafterpack.tmp rm -rf $dumpafterpack.tmp v3=0 v3=`wc -c bavan1 | cut -d' ' -f1` v4=`wc -c bavan2 | cut -d' ' -f1` i=1 if [ $v3 -ne $v4 ] ; then echo "Error: You are comparing two files which dont have equal number of characters" exit 1 else while [ $i -lt $v3 ]; do a1=`echo ${MYARRAY1[*]} | cut -c$i` //this line runs forever,why? a2=`echo ${MYARRAY2[*]} | cut -c$i` //this line runs forever,why? if [ $a1 != $a2 ] then if [ $a1 != "x" ] then echo " $a1 : $a2 " fi fi let i++ done fi
Last edited by Narue; Sep 4th, 2008 at 1:22 pm. Reason: added code tags
![]() |
Similar Threads
- XP not booting - lsass.exe not found (Windows NT / 2000 / XP)
- SpeedUp Your Window XP Never Than Before (Windows tips 'n' tweaks)
- Send data on a serial port (C++)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Using OpenGL in Visual C++: Part I (Game Development)
Other Threads in the Shell Scripting Forum
- Previous Thread: [sh] file operations
- Next Thread: i have doubt in shell scripting
| Thread Tools | Search this Thread |





