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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:41:26+00:00 2026-05-27T17:41:26+00:00

I am using Solaris 5.10 and working on Bash Shell . I have a

  • 0

I am using Solaris 5.10 and working on Bash Shell. I have a shell script in which the following statement not working

ssh 172.18.16.55 "df -h" |grep -w /data1

When I replace /data1 with data1 (i.e removed “/”), it is working correctly.

I have another statement like below which is working fine.

ssh 172.18.16.55 "df -h" |grep -w /dev/dsk/c1t0d0s0

According to my understanding, first occurrence of “/” (forward slash) is not getting recognized by the shell script. I want to know what is the significance of “/” in shell script?
below are my outputs.

root@P020XIDCNF # ssh 172.18.16.55 "df -h" |grep '/data1\>'
/dev/md/dsk/d50         84G    59G    24G    71%    /data1

root@P020XIDCNF # ssh 172.18.16.55 "df -h" |grep -w /data1

does not print anything.


root@P020XIDCNF # ssh 172.18.16.55 "df -h" |grep /data1
/dev/md/dsk/d50         84G    59G    24G    71%    /data1
  • 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-05-27T17:41:27+00:00Added an answer on May 27, 2026 at 5:41 pm

    grep‘s -w option tells to match the pattern as a “word”, i.e., with a “word boundary” before and after it. I think what’s happening is that grep’s idea of a word boundary doesn’t match what you’re expecting.

    You can use \< and \> to match word boundaries explicitly.

    Here are some examples run on a Solaris 9 system:

    % echo /dev/md/dsk/d50 84G 59G 25G 71% /data1 | grep -w /data1
    % echo /dev/md/dsk/d50 84G 59G 25G 71% /data1 | grep '\</data1\>'
    % echo /dev/md/dsk/d50 84G 59G 25G 71% /data1 | grep '/data1\>'  
    /dev/md/dsk/d50 84G 59G 25G 71% /data1
    % 
    

    Apparently Solaris grep doesn’t consider the the boundary between a space and a / character to be a word boundary.

    I suggest running man grep, and probably following some of the “See also” references, to see just how this is documented. (I tried to do that myself, but the Solaris system I have access to is having problems at the moment.)

    If you want to use this command as part of a reasonably portable script, you need to be aware that this is an area where GNU grep behaves differently. I get the following on my Linux system with GNU grep:

    % echo /dev/md/dsk/d50 84G 59G 25G 71% /data1 | grep -w /data1
    /dev/md/dsk/d50 84G 59G 25G 71% /data1
    % echo /dev/md/dsk/d50 84G 59G 25G 71% /data1 | grep '\</data1\>'
    % echo /dev/md/dsk/d50 84G 59G 25G 71% /data1 | grep '/data1\>'  
    /dev/md/dsk/d50 84G 59G 25G 71% /data1
    % 
    

    Note that your question would have been easier to answer if you had shown us the exact line that you expected to be matched.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working solaris 10 and using bash shell. I have a shell script
i have a working solaris 10 server with ssh and NIS using the following
I have a shell script which I'd like to trigger from a J2EE web
I am using Solaris. I have to log into sql plus and run some
I have a program in C using Solaris with VERY ancient compatibility it seems.
I have a Solaris daemon written in Java6. Clients can connect to it using
I have come across a very weird error. I'm on Solaris 10, using Ruby
I have noticed that Solaris 10's Bourne shell, /bin/sh (and also /sbin/sh ) forks
I am using Solaris x86 box . My application crashes with following stack trace.
I am working on Solaris and working on a script that turns on any

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.