Tuesday, 10 March 2015

What is (') Single quote and (") Double quote in Unix

Recently I got one requirement, in which I have to write a Unix shell script which does multiple things such as calling the ESSBASE report script objects and those report scripts should be generated on the fly based on the arguments passed by the user,
Here is the main task where I found very difficulty.
While I am passing the arguments to the script, I tested those arguments by passing them in the single quote to ensure the integrity of the parameters. The later part of the script will call other script using the same arguments and there also I followed the same method by passing the arguments in single quote.
UNIX is very sincere here; it didn’t work because the perception of UNIX for each special character is quite situational.
Here, I came to know how the single and double quote works.
UNIX calls single quote as Strong quotes which shows the arguments integrity at higher level but those characters will not holds good at the lower levels of the script, here you need to use the double quotes which are weak quotes
Single quotes (‘) - Strong quotes.
Double quotes (“) - Weak quotes
Back tact (`) - Command quote.

E.g: abc.cmd ‘xxx yyy ‘yyy zzz’ ‘zzz aaa’ ‘aaa bbb’ (passing argument to a script in single quotes.)

Xyz.cmd which will be called inside abc.cmd with arguments in double quotes. “$1” $2” “$3” “$4”

Happy Learning :)

No comments:

Post a Comment