我有一个简单的脚本,它为我提供了一些文件中的值。我正在使用 sed 来获取那个值(下面给出了语法)。直到昨天,这些命令都运行良好。但是现在当我运行这些命令时我没有得到任何价值。我没有改变任何东西,所以我很惊讶这是什么原因。谁能告诉我如何调试我的问题?以下是文件文本:
May 1 11:59:31 box2 kernel: usb 1-3: new high speed USB device using ehci_hcd and address 24
May 1 11:59:31 box2 kernel: usb 1-3: New USB device found, idVendor=0411, idProduct=0105
May 1 11:59:31 box2 kernel: usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=5
May 1 11:59:31 box2 kernel: usb 1-3: Product: USB-SATA Bridge
May 1 11:59:31 box2 kernel: usb 1-3: Manufacturer: BUFFALO
May 1 11:59:31 box2 kernel: usb 1-3: SerialNumber: 00001412AA38
May 1 11:59:31 box2 kernel: usb 1-3: configuration #1 chosen from 1 choice
May 1 11:59:31 box2 kernel: scsi27 : SCSI emulation for USB Mass Storage devices
May 1 11:59:38 box2 kernel: scsi 27:0:0:0: Direct-Access BUFFALO External HDD PQ: 0 ANSI: 2 CCS
May 1 11:59:38 box2 kernel: sd 27:0:0:0: Attached scsi generic sg6 type 0
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] 976773168 512-byte logical blocks: (500 GB/465 GiB)
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Write Protect is off
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Assuming drive cache: write through
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Assuming drive cache: write through
May 1 11:59:38 box2 kernel: sdf: sdf1
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Assuming drive cache: write through
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Attached SCSI disk
Run Code Online (Sandbox Code Playgroud)
脚本是:
SERIAL=$(sed -n '5s/A.*: //p' filename)
SIZE=$(sed -n '10s/A.*: //p' filename)
MOUNT=$(sed -n '14s/A.*: //p' filename)
Run Code Online (Sandbox Code Playgroud)