Iftach Hyams <[EMAIL PROTECTED]> writes:
> Q: How do I subtract one list from another (one line, no script) ?
> For example :
> ls /A output is : file1 file2 file6 file8 file9
> ls /B output is : file1 file5 file9
> and I want A\B : file2 file6 file8
Probably as many ways to do it as Linux-IL subscribers. The first to
spring to my mind was (bash syntax)
$ diff <(ls A) <(ls B) | awk '/^</ {printf("%s ",$NF)} END {print ""}'
file2 file6 file8
Is that what you need?
The input redirections for diff prevent comparing the files
themselves. The awk part can be made much simpler if you accept
output as a column, i.e.
$ diff <(ls A) <(ls B) | awk '/^</ {print $NF}'
file2
file6
file8
The second variant that occurred to me, used no awk:
$ ls A | grep -vf <(ls B)
file2
file6
file8
or, if format is important,
$ echo $(ls A | grep -vf <(ls B) | tr '\n' ' ')
file2 file6 file8
Hope it helps.
--
Oleg Goldshmidt [EMAIL PROTECTED]
BLOOMBERG L.P. (BFM) [EMAIL PROTECTED]
"Life's not fair, but the root password helps." [S.Travaglia]
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]