ksh / AIX - Differences between lists to a text file

This seems pretty simple, but I cant figure it out. I get stumped on the simple things.

I am running two commands

1) take a listing a directory of files, and filter out the doc_name (which is in a series of extracted files), and place it in a file.

ls -l | awk '{print $9}' | grep out | cut -d. -f1 >> Extracted.out

2) I then have a list of expected files that should have been retrieved -

more Expected.del | cut -d, -f1 >> Original.out

3) My desired output is a listing, something along the lines of -

someCommand Extracted.out Original.out >> Results.out

Results.out
doc_name1 is missing
doc_name2 is missing
doc_name3 is missing

I've tried using a variety of diff, sort, etc.. But I figure that there's a way to use sed/awk to do this, but of which I am a newbie with. Can someone point me in the right direction.
thanks in advance.

you could use:

grep -v -f Extracted.out  Original.out

To get a list of lines in Original.out that don't appear in Extracted.out

How about (untested)

ls *out* | cut -d. -f1 | grep -v -f- Original.out

I will try both of these. I think that both of these solutions are great, and my biggest issue right now is that I am overthinking. I appreciate the feedback

I'm a bit confused what you are trying to do with more Expected.del | cut -d, -f1 >> Original.out You might really want just cut -d, -f1 Expected.del >> Original.out

The more command is not the right tool. At a push, maybe cat that that is also wasteful (search for uuoc in your favourite search engine). It is far better to just use the processing command you choose to read the file rather than push it in through a pipe. It will slow down your processing if you have large files and worse if you repeat the process several times.

Just a thought,
Robin

fgrep -v -x -f is more precise than grep -v -f because it compares the full lines.
For ex bc should not match abc or bcd .
(A halfway approach would be grep -v -w -f that at least checks for word boundaries.)

1 Like
Moderator comments were removed during original forum migration.