Issue
I wanted to insert this lines of code before line number 1 inside the package.json
is there any chance that can help me with this problem?
$ sed -i "1 i\
"scripts": {
"dev": "yarn tailwindcss -i ./src/input.css -o ./src/output.css --watch"
}," package.json
I tried to do a research but it wont fix the problem, btw I am new to shell script.
Solution
You are using "
for sed
command and have "
in your text you are inserting.
do it like:
$ echo hi > package.json
$ cat package.json
hi
$ sed -i '1i"scripts": {\
"dev": "yarn tailwindcss -i ./src/input.css -o ./src/output.css --watch"\
},' package.json
$ cat package.json
"scripts": {
"dev": "yarn tailwindcss -i ./src/input.css -o ./src/output.css --watch"
},
hi
remember don't add any extra space after back slashes \
Answered By - Yaser Kalali Answer Checked By - Timothy Miller (WPSolving Admin)