Results 1 to 3 of 3
Hi Guys,
I'm writing a bash script and need to assign the result of diff to a variable.
diff -u file1 file2
I've tried stuff like
var=${diff -u $file1 $file2} ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-22-2011 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 1
How to assign diff result to a variable in bash script
Hi Guys,
I'm writing a bash script and need to assign the result of diff to a variable.
diff -u file1 file2
I've tried stuff like
var=${diff -u $file1 $file2} where file1 and file2 are variable holding filenames and get an error "bad substitution". I've also tried putting the $file1 and $file2 in quotes along with several other variations. Same error.
What is the correct syntax?
Thanks...
- 08-22-2011 #2Code:
var=$(diff -u $file1 $file2)
You must always face the curtain with a bow.
- 08-24-2011 #3


Reply With Quote

