Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.1then, my command give me a result like this:
A20010101
A20010102
A20010103problem is, i want to compare the list of result with dirB with result such as:
A20010101
A20010105
A20010106
A20010107if 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.

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.

![]() |
![]() |
![]() |

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