1

I have a hdsentinel executable script, and when I type

./hdsentinel 

On the terminal I get info about my HDD health.

When I type:

./hdsentinel >hd.log

I get all that info in the hd.log file.

On location /home/user/Desktop I have a file example. In name of the file above hd.log, I want to input the 3rd line from file example (3rd line is 192.168.1.1) and result to be hd192.168.1.1.log. How to do this?

  • please share the output of ./hdsentinel – msp9011 May 22 '18 at 11:55
  • Hard Disk Sentinel for LINUX console 0.17.8556 (c) 2016 info@hdsentinel.com Start with -r [reportfile] to save data to report, -h for help Examining hard disk configuration ... HDD Device 0: /dev/sda HDD Model ID : TOSHIBA MQ01ACF050 HDD Serial No: X6L8C1ACT HDD Revision : AV0D2C HDD Size : 476940 MB Interface : S-ATA Gen3, 6 Gbps Temperature : 38 °C Highest Temp.: 46 °C Health : 100 % Performance : 100 % – Savke May 22 '18 at 11:59
1

Try this, Here I am using sed to print the nth ( 3rd ) line of a file example and use the result of the expression $(sed '3q;d' <example-file-path>) in the output file name

./hdsentinel > "hd$(sed '3q;d' /home/user/Desktop/example).log"

Explanation:

sed 'NUMq;d' file

Where NUM is the number of the line you want to print; so, for example, sed '3q;d' file to print the 3rd line of file.

NUMq will quit immediately when the line number is NUM.

d will delete the line instead of printing it.

So all lines, except the NUMth will be deleted because the q causes the rest of the script to be skipped when quitting.

  • 2
    sed 's/man/girl/' you are most welcome :) – Arushix May 22 '18 at 12:23
  • @Arushix ... hahaha.. best comment I have read so far... – msp9011 May 22 '18 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.