I have the following line in a bash script:
disk_info=$(smartctl -i $disk)
where $disk is the name of a disk eg. /dev/sda
The output of the command should be many lines long, and I need to further process these as seperate lines, but the variable $disk_info does not contain any newlines, just spaces in their place
Example:
echo $disk_info
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.15.0-56-generic] (local build) Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: WDC HGST Ultrastar He10 Device Model: WDC WD100EMAZ-00WJTA0 Serial Number: JEJ84B7N LU WWN Device Id: 5 000cca 267dfe25a Firmware Version: 83.H0A83 User Capacity: 10,000,831,348,736 bytes [10.0 TB] Sector Sizes: 512 bytes logical, 4096 bytes physical Rotation Rate: 5400 rpm Form Factor: 3.5 inches Device is: In smartctl database [for details use: -P show] ATA Version is: ACS-2, ATA8-ACS T13/1699-D revision 4 SATA Version is: SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s) Local Time is: Fri Mar 31 22:06:30 2023 CEST SMART support is: Available - device has SMART capability. SMART support is: Enabled
What am I doing wrong as the output ends up as a single line instead of multiple separate lines, separated by LFs
Edit: Note for people coming across this question in the future: As can be seen from the accepted answer, My initial diagnosis of the problem was way off