| | |
Challenging Script
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Cool. What do you have so far, and what problem are you having with it.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
What do you mean by this? This forum is for Linux/Unix Shell Scripting, not Windows Batching (unless things have changed).
As far as doing the comparisons, an easy, but not necessarily performant way is a simple grep command.
As far as doing the comparisons, an easy, but not necessarily performant way is a simple grep command.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
a's got 100
b's got 9
you need the 91 uniques - I'll put 'em in c.txt
Sorry - just needed to drop a post somewhere - it's been a while
, Mike
b's got 9
you need the 91 uniques - I'll put 'em in c.txt
Shell Scripting Syntax (Toggle Plain Text)
while read line do grep $line b.txt >/dev/null 2>&1 if [ $? -ne 0 ] then echo $line >>c.txt fi done <a.txt
Sorry - just needed to drop a post somewhere - it's been a while

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
•
•
a's got 100
b's got 9
you need the 91 uniques - I'll put 'em in c.txt
Shell Scripting Syntax (Toggle Plain Text)
while read line do grep $line b.txt >/dev/null 2>&1 if [ $? -ne 0 ] then echo $line >>c.txt fi done <a.txt
Sorry - just needed to drop a post somewhere - it's been a while
, Mike
Shell Scripting Syntax (Toggle Plain Text)
cp b.txt /tmp/b1.txt while read line do grep -v $line /tmp/b1.txt >/tmp/b2.txt 2>/dev/null mv -f b2.txt b1.txt done <a.txt mv b1.txt c.txt
Last edited by masijade; Nov 17th, 2007 at 5:58 am.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Oct 2007
Posts: 23
Reputation:
Solved Threads: 0
Masijade,
I finished the file comparison in MS Access.But I am trying to do the same file comparison using Shell script...Thats why posted you a thread..
I didn't understand this line in your script :
grep -v $line /tmp/b1.txt >/tmp/b2.txt 2>/dev/null
Can you please explain?
Thanks in advance
Regards
dave.....
I finished the file comparison in MS Access.But I am trying to do the same file comparison using Shell script...Thats why posted you a thread..
I didn't understand this line in your script :
grep -v $line /tmp/b1.txt >/tmp/b2.txt 2>/dev/null
Can you please explain?
Thanks in advance
Regards
dave.....
•
•
Join Date: Oct 2007
Posts: 23
Reputation:
Solved Threads: 0
•
•
•
•
a's got 100
b's got 9
you need the 91 uniques - I'll put 'em in c.txt
Shell Scripting Syntax (Toggle Plain Text)
while read line do grep $line b.txt >/dev/null 2>&1 if [ $? -ne 0 ] then echo $line >>c.txt fi done <a.txt
Sorry - just needed to drop a post somewhere - it's been a while
, Mike
Mike,
why are you using ">/dev/null 2>&1" in your script?
What condition you are checking in your "if" loop?
Regards
Dave
Last edited by dave_nithis; Nov 19th, 2007 at 7:57 am.
•
•
•
•
Masijade,
I finished the file comparison in MS Access.But I am trying to do the same file comparison using Shell script...Thats why posted you a thread..
I didn't understand this line in your script :
grep -v $line /tmp/b1.txt >/tmp/b2.txt 2>/dev/null
Can you please explain?
Thanks in advance
Regards
dave.....
The next line then moves b2.txt to b1.txt so you can repeat the procedure with the next line. Once you have gone through all lines, b2.txt contains all lines from b that were not in a.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- Clean Previous Next Script for MySQL results (PHP)
- The name for the Resize Button to ad to Script (HTML and CSS)
- Random Programming Script (Computer Science)
- Importing SQL Script File - Urgent !! (Database Design)
- Script problems with IE (Web Browsers)
- Help with shell script to auto gzip a .sql dump after backup (Shell Scripting)
- Adding mutiple PC's to an OU via script? (Windows NT / 2000 / XP)
- Table of Contents Script (Java)
- ASP slow-down server script (ASP)
Other Threads in the Shell Scripting Forum
- Previous Thread: shell script
- Next Thread: need help with figuring out sizeof in bash script
| Thread Tools | Search this Thread |






