Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9288849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:00:32+00:00 2026-06-18T20:00:32+00:00

The following is a snippet from a daily report script that checks on the

  • 0

The following is a snippet from a daily report script that checks on the SMART status of disks.

I’d like the full value of $STATUS to be printed in the ‘else’ clause, however, but it’s truncating it now to only the first word ($3).

How can I overcome this?

echo "SMART STATUS" >> $LOGS
echo "--------------------------" >> $LOGS
DISKS=( 0 1 2 3 4 5 6 7 )

for i in "${DISKS[@]}" ;

do

STATUS=`diskutil info /dev/disk$i | grep SMART | awk '{ print $3 }'`

if [ "$STATUS" = "Verified" ]; then
        echo "SMART STATUS OK FOR DISK $i" >> $LOGS
else

        echo "** SMART STATUS $STATUS FOR DISK $i **" >> $LOGS
fi
done

echo " " >> $LOGS
echo " " >> $LOGS

For example:

$ diskutil info /dev/disk8 | grep SMART                     
   SMART Status:             Not Supported
$ diskutil info /dev/disk2 | grep SMART 
   SMART Status:             Verified

Ideally the script would echo “Not Supported” for cases like disk8. I think the value for “SMART Status:” may vary between one word and several. I don’t see all the possibilities on the man page, so I don’t have a definitive answer for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:00:33+00:00Added an answer on June 18, 2026 at 8:00 pm

    You can save the grep, and put all things in awk:

    try this:

    STATUS=$(diskutil info /dev/disk$i|awk -F': *' '/SMART/{print $2}')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following snippet below from my script that's using a WebRequest to
I have the following code snippet from my PowerShell script that... Loops through a
The following snippet from RuntimeUtil.java from jlibs guarantees GC that garbage collection is done.
I have the following snippet from a query that I'm rebuilding: LEFT JOIN (SELECT
I have this following snippet from c++ code that is used for encryption: EVP_CIPHER_CTX
I extracted the following snippet from Profiler (from a statement that fails due to
I have the following source snippet from a book that I'm reading now. So
The following is a snippet from a PhantomJS script. It tracks dynamic content on
I have the following snippet from my code: switch ($extention) { case gif: $src
The following code snippet is from The Official GNOME 2 Developer's Guide : GMemChunk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.