LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-21-2008, 01:49 PM   #1
Vikenoshi
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Rep: Reputation: 0
Question bad interpreter


Hi,
I am a newbie here, I am in training
I have commands in a file called "copycat" like below :


#!/usr/bin/bash
read -p "Please input original string: " oldString
read -p "Please input the new string: " newString
sed -i "s/$oldString/$newString/g" $*


and these are steps what I do:

[user@selina ~]$ cd HW1
[user@selina HW1]$ chmod u+x copycat
[user@selina HW1]$ ./copycat *.c
-bash: ./copycat: /bin/bash^M: bad interpreter: 瘝奨?甇支?瑼鯏??緐澻??

I don't know where I got wrong.
If anyone can help me, I am so appreciate it.
 
Old 03-21-2008, 02:06 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Code:
-bash: ./copycat: /bin/bash^M: bad interpreter:
It looks like a file coming from Windows: the ^M sequence stats for "carriage return" plus "newline" control characters, that is the sequence \r\n in Unix. You have to strip away these control character. One way is by the dos2unix command:
Code:
dos2unix copycat
or you can use sed in this way
Code:
 sed -i 's/^M//g' copycat
where you type ^M by pressing Ctrl-V and Ctrl-M in sequence. Hope this will help.
 
Old 03-21-2008, 02:24 PM   #3
Vikenoshi
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Original Poster
Rep: Reputation: 0
code:
dos2unix copycat

It works !! Thanks a lot >.<
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bad ELF interpreter dfw123 Linux - Newbie 2 05-07-2007 07:04 PM
bad interpreter in script c0d3 Programming 11 12-15-2004 04:48 AM
bad interpreter???? yenonn Programming 4 09-25-2004 05:21 AM
bad interpreter / not enough cc in $PATH sneeze Linux - Software 7 07-05-2003 02:34 PM
bad interpreter penzilsinc Linux - Newbie 5 06-26-2002 01:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration