0

I realize that the diff command is reserved for directories/files, but I've seen it being able to read from standard input, so that's not necessarily true.

Is it possible to somehow compare two variables that were stored in a ksh script?

The code looks like this:

a=$(cut -c 1-10 first_file.txt)
b=$(cut -f '3' -d ' ' second_file.txt)

#what I would like to do
$(diff $a $b) > differences.txt
John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
Nitrodist
  • 316
  • 3
  • 13

1 Answers1

1

Use process substution (thanks, Dennis!) as described here. This would probably do it

diff <(echo $a) <(echo $b)

At least, that worked for me in bash on cygwin.

mfinni
  • 36,144
  • 4
  • 53
  • 86