【发布时间】:2015-03-16 15:00:45
【问题描述】:
我想找到连接到机器的设备的 USB 端口。我用了命令
dmseg | grep "ttyUSB" | grep "attached"
我得到了输出
[ 525.763315] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
[ 525.796039] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB1
但我只需要端口。所以我使用了命令
cut -d ' ' -f14
我明白了
ttyUSB0
ttyUSB1
我想用这个输出替换文件的值。所以我使用了 se 命令
sed -i "s/\b\SERIAL_INTERFACE=\b.*/SERIAL_INTERFACE=$(dmesg | grep "ttyUSB" | grep "attached" | cut -d ' ' -f13)/g" /home/ubuntu/webserver/properties.cfg
但它显示错误 sed: -e expression #1, char 46: unterminated `s' command
帮我解决这个问题。
提前谢谢你。
【问题讨论】:
-
看起来您正在使用双引号将参数分隔到 sed 并且还在表达式中使用双引号。
-
尝试转义双引号
-
提供您的示例输入文件和预期输出。