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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:08:35+00:00 2026-06-11T14:08:35+00:00

I am storing bash scripts onto a CentOS server from PHP over SSH2 ;

  • 0

I am storing bash scripts onto a CentOS server from PHP over SSH2; I know it is complicated, but just bear with me.

When I open up the file (on the server):

vi myScript

I see:

ls -al^M
free -m

So, when I try an execute it with:

bash myScript

The output throws an error:

ls: invalid option -- 
Try `ls --help' for more information.
         total       used       free     shared    buffers     cached
Mem:           676        642         34          0         33        313
-/+ buffers/cache:        295        380
Swap:          767          1        766

What is the ^M and any idea where it is coming from? The bash script should to be able to support newlines and tabs.

Thanks.

  • 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-11T14:08:36+00:00Added an answer on June 11, 2026 at 2:08 pm

    ^M is end of line coming from Windows. The file was created in Windows initially. You may do in vi something like :1,$ s/^v^M//g to delete those.

    Also you can use dos2unix command on the entire file to clean it in one shot. You can do it before execution of script.

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

Sidebar

Related Questions

In bash I would like to get filename from a command line string. But
Sorry if this seems like a dumb question but I am just learning bash
I've written bash scripts before, but I'm a little confused about how to do
In my bash script I need to extract just the path from the given
I do the following in my scripts: ~/tmp$ cat quick.sh #!/bin/bash TEXT=Hello World KEY=$(echo
In my bash script I have an external (received from user) string, which I
In one of my bash scripts I have this variable, containing a list of
I have this bash script on the server that runs every hour, via cron.
[CentOS, BASH, cron] Is there a method to declare variants that would keep even
I've written a bash logging library to be implemented with some complex scripts that

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.