I have written a very simple script which takes a string as input and replace the input text in a file via sed. But I get an error always sed: -e expression #1, char 40: unknown option to `s'Shell script is as belowsed -i s/c9/$1/g Test.java and to run./code.sh lmc.driver.findElement(By.xpath(\//*[@id=\\\login-email\\\]\)).clear();\n                        lmc.driver.findElement(By.xpath(\//*[@id=\\\login-email\\\]\)).sendKeys(username);\n                        lmc.driver.findElement(By.xpath(\//*[@id=\\\login-password\\\]\)).clear();\n                        lmc.driver.findElement(By.xpath(\//*[@id=\\\login-password\\\]\)).sendKeys(password);\n                        lmc.driver.findElement(By.xpath(\//*[@id=\\\loginForm\\\]/div[3]\)).click();\n                        lmc.driver.findElement(By.xpath(\//*[@id=\\\login-identity-domain\\\]\)).clear();\n                        lmc.driver.findElement(By.xpath(\//*[@id=\\\login-identity-domain\\\]\)).sendKeys(tenantId);\n                        lmc.driver.findElement(By.xpath(\//*[@id=\\\loginBtn\\\]\)).click();
Sed giving error when taking input from command line
linux;sed
The string contains unescaped //. After inserting the string the first one will close the substitution, the second will be the unknown option.You either have to escape the slashes with backslashes to sed (which need to be escaped to the shell, so you need double-backslashes, resulting in ugly\\/\\/ or better use a different delimiter to the s command which is not part of the string likesed -i s_c9_$1_g Test.javaThis way the slashes lose their special meaning.