Skip to content
Advertisement

Assignment of variables in shell scripting

I am trying to write a shell script to simulate the following problem:

File A contains some entries like

JavaScript

and File B contains

JavaScript

the final file should have
(contents of file b which are not there in file a)

JavaScript

I was trying something like this but it’s not working:

JavaScript

Advertisement

Answer

You code has some errors:

  1. forgot the closure of if statement : fi

  2. “grep $i a” must be interpreted as a command , such as $(grep $i a) or `grep $i a`

  3. You must add some characters around $(grep $i a) avoid empty string comparasion , such as “:” or something else, whatever.

Solution:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement