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 8942353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:29:39+00:00 2026-06-15T11:29:39+00:00

I am using @df -lH | grep \/Volumes/*\ | awk ‘{$1=$2=$3=$4=$5=$6=$7=$8\\; print $0 }’

  • 0

I am using @"df -lH | grep \"/Volumes/*\" | awk '{$1=$2=$3=$4=$5=$6=$7=$8\"\"; print $0 }'" for getting locally-mounted volumes path. but if volume name contain two or more space (Leopard 1). its(awk) removing space from output.

Output:

$df -lH

Filesystem     Size   Used  Avail Capacity  Mounted on
/dev/disk0s3    81G    61G    19G    77%    /
/dev/disk0s2    81G    72G   8.2G    90%    /Volumes/Leopard  1  2     3
/dev/disk0s4   158G    47G   111G    30%    /Volumes/Backup  

$ df -lH | grep "/Volumes/*"
/dev/disk0s2    81G    72G   8.2G    90%    /Volumes/Leopard  1  2     3
/dev/disk0s4   158G    47G   111G    30%    /Volumes/Backup  

$ df -lH | grep "/Volumes/*" | awk '{$1=$2=$3=$4=$5=""; print $0}'
     /Volumes/Leopard 1 2 3
     /Volumes/Backup

can anyone please help me out?

  • 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-15T11:29:40+00:00Added an answer on June 15, 2026 at 11:29 am

    By default awk‘s output field separator is a single space. So the output of your awk command is completely expected. To get the result you want, you’ll need to use some sort of regex, so try this instead with GNU awk:

    df -lH | awk '/Volumes/ { sub(/^(\S+\s+){5}/, ""); print }'
    

    Or if you have GNU sed:

    df -lH | sed -nr '/Volumes/s/^(\S+\s+){5}//p'
    

    Results:

    /Volumes/Leopard  1  2     3
    /Volumes/Backup  
    

    EDIT:

    I see that BSD/OSX awk doesn’t support interval expressions unfortunately. Therefore the safest way would be to do this with awk:

    df -lH | awk '/Volumes/ { sub(/^[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +/, ""); print }'
    

    or with sed:

    df -lH | sed -n '/Volumes/s/^[^ ]\+ \+[^ ]\+ \+[^ ]\+ \+[^ ]\+ \+[^ ]\+ \+[^ ]\+ \+[^ ]\+ \+//p'
    

    This should also be highly portable! HTH.

    EDIT:

    For Mac OSX 10.8 with 8 columns, simply extend the regex:

    df -lH | awk '/Volumes/ { sub(/^[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +/, ""); print }'
    

    or with sed:

    df -lH | sed -n '/Volumes/s/^[^ ]\+ \+[^ ]\+ \+[^ ]\+ \+[^ ]\+ \+[^ ]\+ \+//p'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using grep to extract parts from a file but I'm having trouble making
Consider the following command line output using grep: [gjempty@gjempty]$ find . -name *.php |
I search in the Mozilla folder using: grep -R About Mozilla Firefox ./* but
One of my homework questions is to search using grep an lines that contain
After using grep command, i will give you a small example grep test test
I've been using grep -f to obtain patterns from one file and extract lines
I have been using grep with perl extension for multiline match .However it turns
I am using grep to find out all occurences of a VB function call.
Is there an easy way using grep (or combine with other standard command line
I'm pulling JSON data fromlocalstorage and using grep to filter out the items needed

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.