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

  • Home
  • SEARCH
  • 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 8499669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:43:48+00:00 2026-06-11T00:43:48+00:00

#!/bin/bash # This file will fix the cygwin vs linux paths and load programmer’s

  • 0
#!/bin/bash
# This file will fix the cygwin vs linux paths and load programmer's notepad under windows.
# mail : <sandundhammikaperera@gmail.com> 
# invokes the GNU GPL, all rights are granted.


# check first parameter is non empty.
# if empty then give a error message and exit.
file=${1:?"Usage: pn filename"};

if [[ "$file" == /*/* ]] ;then
  #if long directory name.
# :FAILTHROUGH:
  echo "$0: Executing pn.exe $file" 

else 
  file="$(pwd)/$file";
fi

#check whether the filename starts with / if so replace it with appropriate prefix #
prefix="C:/cygwin/";

#check for the partterns starting with "/" #
echo $var | grep "^/*$"
if [[ "$?" -eq "0" ]] ;then
  # check again whether parttern starts with /cygdrive/[a-z]/ parttern #
  if [[ $file == /cygdrive/[a-z]/* ]] ; then 
    file=${file#/cygdrive/[a-z]/};
    file="C:/"$file;
  else
    file="$prefix""$file";  
  fi 
fi


#check for the appropriate file permissions #
# :TODO: 


echo $file
exec "/cygdrive/c/Program Files (x86)/Programmer's Notepad/pn.exe"  $file 

as I in my program which convert path names between cygwin and windows and load
the pn.exe [ programmer’s notepad in windows]. So my questions are,

  1. There are built in regex expression for the “[[” or ‘test’ operator. (as well as
    I used them in my above program). But why they don’t work in here if I change,

    echo $var | grep "^/*$"
    if [[ "$?" -eq "0" ]] ;then
    

    to this,

    if [[ "$file" == ^/*$ ]] ;then
    

    What is the reason for that? Is there any workaround?
    I have already tried the second method [[ "$file" == ^/*$ ]] but it didn’t work.
    then , simple googling brought to me here: http://unix.com/shell-programming

  2. How to find all the documentation about [[ operator or ‘test’ command? I have used
    man test but :(. Which document specifies it’s limitations on regex usage if there so.

  • 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-11T00:43:50+00:00Added an answer on June 11, 2026 at 12:43 am

    First, grep "^/*$" will only match paths containing only slashes, like “/”, “///”, “////”. You can use grep "^/" to match paths starting with a slash. If you want to use bash regexes:

    var="/some"
    #echo $var | grep "^/"
    if [[ "$var" =~ ^/ ]] ;then
      echo "yes"
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script: #!/bin/bash SINGLE_FILE=/tmp/blah.file MULTIPLE_FILES=/tmp/{dir1,dir2}/*.file cp $SINGLE_FILE $MULTIPLE_FILES /tmp/newDir This will fail
:/usr/local/bin# file wkhtmltopdf wkhtmltopdf: Mach-O executable i386 This file will not run. I have
Hopefully this should be a simple one... Here is my test.sh file: #!/bin/bash patch_file=/home/my
I am writing a script which will do this: #!/bin/bash mysqldump -u user -p
On my Centos 6.2 I have this bash script: [le_me]$ cat get.nb #! /bin/bash
This code... #!/bin/bash cond=10; for i in {1..$cond} do echo hello; done ...just drives
How can I make this code work? #!/bin/bash ARRAYNAME='FRUITS' FRUITS=( APPLE BANANA ORANGE )
Why is this script executing the string in the if statement: #!/bin/bash FILES=* STRING=''
I am working on a Bash shell script that does something like this: #!/bin/bash
For testing purposes I have this shell script #!/bin/bash echo $$ find / >/dev/null

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.