LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 10-31-2012, 02:17 AM   #1
slowerogue
Member
 
Registered: Oct 2012
Posts: 96

Rep: Reputation: Disabled
how to modify sh file type from "dos" to "sh"


hi guys, i have created a xx.sh file and it was able to run properly on linux
using winscp, i copied it to windows few weeks ago.
and i needed to use it again and i copy it back to linux.

now the xx.sh file still can run properly, but the output will have a ? after the filename
eg. topout?
and when i vi xx.sh, it show a [dos].
pls check the image
http://i.imgur.com/0pmB0.png
 
Old 10-31-2012, 02:42 AM   #2
codemaniac
Member
 
Registered: Feb 2010
Location: INDIA
Distribution: Slackware,Suse,Mint
Posts: 39

Rep: Reputation: 17
Quote:
Originally Posted by slowerogue View Post
hi guys, i have created a xx.sh file and it was able to run properly on linux
using winscp, i copied it to windows few weeks ago.
and i needed to use it again and i copy it back to linux.

now the xx.sh file still can run properly, but the output will have a ? after the filename
eg. topout?
and when i vi xx.sh, it show a [dos].
pls check the image
http://i.imgur.com/0pmB0.png
If you are using a Unix system ,then you can find "dos2unix" utility .
Else you can make it yourself like below.

Code:
dos2unix(){
  tr -d '\r' < "$1" > t
  mv -f t "$1"
}
dos2unix file

unix2dos(){
  sed -i 's/$/\r/' "$1"
}

unix2dos file
 
Old 10-31-2012, 02:49 AM   #3
slowerogue
Member
 
Registered: Oct 2012
Posts: 96

Original Poster
Rep: Reputation: Disabled
i m using rhel..
 
Old 10-31-2012, 10:44 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,433

Rep: Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506
The dos2unix program should be available in RHEL, though you might not have it installed. The package name is "dos2unix". You might also want to install the "unix2dos" package.

Last edited by rknichols; 10-31-2012 at 10:46 AM.
 
Old 10-31-2012, 10:11 PM   #5
slowerogue
Member
 
Registered: Oct 2012
Posts: 96

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
The dos2unix program should be available in RHEL, though you might not have it installed. The package name is "dos2unix". You might also want to install the "unix2dos" package.
thanks alot, this worked
 
  


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
how can I "cat" or "grep" a file to ignore lines starting with "#" ??? callagga Linux - Newbie 7 08-16-2013 06:58 AM
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 06:41 PM
executing "DOS/Windows executable" files from "/media" Ruarscampbell Linux - Newbie 10 07-05-2011 05:48 PM
How to get the "data type" of an "unknown variable" in "C Language" ? Affair Programming 8 06-20-2009 12:30 PM
Cedega from Fat32 (Invalid path "." given for "--use-dos-cwd") bdox Linux - Software 0 03-30-2005 11:24 AM


All times are GMT -5. The time now is 06:35 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