Computing.Net > Forums > Unix > comparison problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

comparison problem

Reply to Message Icon

Name: clemeot
Date: June 7, 2001 at 01:07:37 Pacific
Comment:

hello, please help.

i use this command (ls dirA |cut -d. -f1 |uniq) to do listing on a list of files under dirA.
files name example:
A20010101.1
A20010101.2
A20010102.1
A20010103.1

then, my command give me a result like this:
A20010101
A20010102
A20010103

problem is, i want to compare the list of result with dirB with result such as:
A20010101
A20010105
A20010106
A20010107

if i want to know whether dirA & dirB got same result(either line), then it will echo something to let me know. for the echo is no problem at all.problem is i do not know how to compare.

i already try to use for-do-done, grep, ls,...(etc);still cannot.



Sponsored Link
Ads by Google

Response Number 1
Name: tom z.
Date: June 7, 2001 at 03:33:15 Pacific
Reply:

Not sure, but if 2 things exist/work then the following should work, dirB must already exist and diff can accept piped inputs:

ls dirA |cut -d. -f1 |uniq | diff dirB

If not then you will have to do this:

ls dirA | cut -d. -f1 | uniq > dirA; diff dirA dirB

If there is no difference, nothing is returned, if there is a differnce you are usually returned a cryptic set of differnces which includes ed/vi instructions on how to make the files match.

Hope this helps, good luck.



0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: comparison problem

ksh while loop problem www.computing.net/answers/unix/ksh-while-loop-problem/5133.html

Help: problems installing 9 gig hd in SCO UNIX 3.2v4 www.computing.net/answers/unix/help-problems-installing-9-gig-hd-in-sco-unix-32v4/1648.html

FTP File Size Problem from UNIX to www.computing.net/answers/unix/ftp-file-size-problem-from-unix-to/4240.html