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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:35:39+00:00 2026-05-29T05:35:39+00:00

I opened Terminal from my MacBook Pro, and try to run some bash script

  • 0

I opened “Terminal” from my MacBook Pro, and try to run some bash script from book “Bash Guide for Beginners”:

first I checked the PATH environment setting and current working folder, which contains a script “script1.sh”:

unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ pwd
/Users/liuren/Documents/myscript
unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ ls
script1.sh

then I set the PATH to include current working folder, and it seems succeeded:

unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ export PATH="$PATH:/Users/liuren/Documents/myscript"
unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/liuren/Documents/myscript

however I can’t get the “script1.sh” running:

unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ script1.sh
#: bad interpreter: No such file or directoryt1.sh: /bin/bash

unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ ./script1.sh
#: bad interpreter: No such file or directory

The script is actually very simple, from “Bash Guide for Beginners”:

#!/bin/bash
# This script clears the terminal, displays a greeting and gives information
# about currently connected users.  The two example variables are set and displayed.
clear                           # clear terminal window
echo "The script starts now."
echo "Hi, $USER!"               # dollar sign is used to get content of variable
echo
echo "I will now fetch you a list of connected users:"
echo
w                               # show who is logged on and
echo                            # what they are doing
echo "I'm setting two variables now."
COLOUR="black"
VALUE="9"
echo "This is a string: $COLOUR"
echo "And this is a number: $VALUE"
echo
echo "I'm giving you back your prompt now."
echo

, and there is actually “/bin/bash”:

unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ cd /bin
unknown_b8-8d-1b-3d-0b-3d:bin liuren$ ls
[       df      launchctl   pwd     tcsh
bash        domainname  link        rcp     test
cat     echo        ln      rm      unlink
chmod       ed      ls      rmdir       wait4path
cp      expr        mkdir       sh      zsh
csh     hostname    mv      sleep
date        kill        pax     stty
dd      ksh     ps      sync
unknown_b8-8d-1b-3d-0b-3d:bin liuren$ 

Using other ways to run it, it shows no result

unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ source script1.sh
unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ bash script1.sh
unknown_b8-8d-1b-3d-0b-3d:myscript liuren$ bash -x script1.sh

I guess it didn’t work. How can I fix this issue?

ps. what is this “unknown_b8-8d-1b-3d-0b-3d”, is it possible to change it to a more meaningful thing?

  • 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-29T05:35:40+00:00Added an answer on May 29, 2026 at 5:35 am

    I’ve seen this before when a shebang line has DOS-style line endings (usually when it was created on a Windows PC).

    If you do cat -vet ./script1.sh, you will probably see:

    #!/bin/bash^M$
    [...]
    

    Remove those carriage returns and you’ll be set.

    One way to do this is:

    tr -d '\r' <  ./script1.sh > ./script2.sh
    

    …which will create a new file (./script2.sh) without the carriage returns.

    If you make ./script2.sh executable (chmod +x ./script2.sh), you should be able to run it (without needing to update ${PATH}, it’s usually a bad plan to have the current directory in your ${PATH}‘,

    To find out all of the elements of your prompt (unknown_b8-8d-1b-3d-0b-3d:myscript liuren$), et al, use:

    echo $PS1
    

    This will contain characters like \w, which are expanded to the current working directory, for example.

    You can see a full list of these codes in the Bash Reference Manual.

    Happy scripting!

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

Sidebar

Related Questions

I have a .vimrc script that automatically creates a buffer for a bash terminal
I got this code from Andy Tanenbaum's book. I am trying to run it.
I've got two terminal instances/processes opened with different PID. Is it possible to from
I have a Ruby script that I built in TextMate and can successfully run
I opened a javaScript file in a javaScript time.... document.write(<script src='newnote.js' type='text/javascript'></script>); is there
On a MacBook Pro with Mac OS X version 10.6.7, I have a simple
I have wrote a c program in gedit and opened terminal where the following
I opened my Mac terminal and it said, You have mail . I didn't
Is it possible to open a new tab in Mac OS X's terminal from
in linux, I opened terminal and input python2.7 and then input the codes as

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.