David Custer
David Custer

Reputation: 651

sed working on one line, but not the other

here are a couple lines of the script, everything works except for the first line.

sed -i '/    "download-dir": "/var/lib/transmission/Downloads", /c\    "download-dir": "/media/hdd_bottom_left/transmission/downloads", ' /var/lib/transmission/settings.json
sed -i '/    "download-queue-size": 5, /c\    "download-queue-size": 6, ' /var/lib/transmission/settings.json
sed -i '/    "peer-limit-global": 200, /c\    "peer-limit-global": 1200, ' /var/lib/transmission/settings.json
sed -i '/    "peer-limit-per-torrent": 50, /c\    "peer-limit-per-torrent": 180, ' /var/lib/transmission/settings.json
sed -i '/    "port-forwarding-enabled": true, /c\    "port-forwarding-enabled": false, ' /var/lib/transmission/settings.json
sed -i '/    "rpc-whitelist": "127.0.0.1", /c\    "rpc-whitelist": "127.0.0.1,10.0.1.2,10.0.1.3", ' /var/lib/transmission/settings.json
sed -i '/    "script-torrent-done-enabled": false, /c\    "script-torrent-done-enabled": true, ' /var/lib/transmission/settings.json
sed -i '/    "script-torrent-done-filename": "", /c\    "script-torrent-done-filename": "/media/hdd_bottom_left/transmission/script/post-process", ' /var/lib/transmission/settings.json
sed -i '/    "speed-limit-up": 100, /c\    "speed-limit-up": 5000, ' /var/lib/transmission/settings.json
sed -i '/    "speed-limit-up-enabled": false, /c\    "speed-limit-up-enabled": true, ' /var/lib/transmission/settings.json
sed -i '/    "upload-slots-per-torrent": 14, /c\    "upload-slots-per-torrent": 11, ' /var/lib/transmission/settings.json

here is the error:

[root@Server transmission]# sed -i '/    "download-dir": "/var/lib/transmission/Downloads", /c\    "download-dir": "/media/hdd_bottom_left/transmission/downloads", ' /var/lib/transmission/settings.json
sed: -e expression #1, char 55: expected newer version of sed
[root@Server transmission]# 

Upvotes: 0

Views: 3353

Answers (1)

tkausl
tkausl

Reputation: 14269

You need to escape the delimiter (/) if you want/need to use them in the expression:

sed -i '/    "download-dir": "\/var\/lib\/transmission\/Downloads", /c\    "download-dir": "\/media\/hdd_bottom_left\/transmission\/downloads", ' /var/lib/transmission/settings.json

Upvotes: 3

Related Questions