odd character (^M) from .sh when chagining to .ksh


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers odd character (^M) from .sh when chagining to .ksh
# 1  
Old 05-23-2008
odd character (^M) from .sh when chagining to .ksh

// AIX 5.3

I am trying to use .sh after changing it to .ksh
Obviously, it doesn't like the file extension change.
I am seeing a lot of odd characters (^M) like below:

Init_Part2 ()^M^M
{^M^M
AWTRACE "AW SET"^M^M
set | grep -e CFG_ -e OUTDIR_ENV^M^M
AWTRACE "AW SET"^M^M
^M^M
if [ "$OUTDIR" = "" ] ; then^M^M
OUTDIR="." # >AW020<^M^M
fi^M^M
AWTRACE "AW000I OUTDIR=${OUTDIR}"^M^M
AWTRACE "AW000I OUTDIR_ENV=${OUTDIR_ENV}"^M^M
^M^M

How do you remove this odd character (^M)? Smilie
The .sh file is large, and manual work is merely possible.

thx much
# 2  
Old 05-23-2008
this is a DOS "return". use "dos2unix" command (depends on your os) to change from DOS to unix file format.
# 3  
Old 05-24-2008
file is in dos format change file format to unix

open file in vim
Code:
:se ff=unix 
:wq!

thats it.

if u dont have vim use vi
Code:
:%s/^M//g

^M - (control-V + control-M)

or
Code:
perl -pi -e 's/^M//g' <filename>

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replace character in odd or even lines

Hello, I'm here again asking for your precious help. I'm writing some code to convert csv files to html. I want to highlight header and also I want to have rows with alternate colors. So far this is my work###Let's format first line only with some color cat $fileIN".tmp1" | sed '1... (7 Replies)
Discussion started by: emare
7 Replies

2. Shell Programming and Scripting

ksh - Get last character from string - Bad Substitution error

I want to get the last character from my machine name using the following code, the default shell is bash, the script runs in ksh. I get 'bad' substitution error on running the script, but works fine if run using dot and space. Why? $ echo $0 bash $ cat -n myenv.sh 1 ... (8 Replies)
Discussion started by: ysrini
8 Replies

3. Shell Programming and Scripting

ksh escape a character

friends, I have a situation where i am using a $RANDOM function along with the filename, I want this to be escaped by the OS in the first assignment (works as expected) and executed in the second assignment (does not execute $RANDOM) filename1=filename1_\$RANDOM echo $filename1... (3 Replies)
Discussion started by: Balaji M
3 Replies

4. Shell Programming and Scripting

please explain why this ksh echo deletes character

Please explain why this works. Am unable to find another definition for the '%', which would explain this behaviour: spaceLeft=`df -h /myPartition | tail -1` # output looks like: /dev/sda5 10G 1.2G 12G 29% / set -- $space #this deletes the trailing '%' sign, which is... (6 Replies)
Discussion started by: frododot
6 Replies

5. Shell Programming and Scripting

KSH: substitution character, AWK or SED?

Hi Gurus, I am working with a korn shell script. I should replace in a very great file the character ";" with a space. Example: 2750;~ 2734;~ 2778;~ 2751;~ 2751;~ 2752;~ what the fastest method is? Sed? Awk? Speed is dead main point, Seen the dimensions of the files Thanks (6 Replies)
Discussion started by: GERMANICO
6 Replies

6. UNIX for Dummies Questions & Answers

Odd Control Character issue ^A

Sorry to bug you, but my sed is failing me, I have a file auto generated from abinitio, it has a string of chars ending with a line break, and then it has added a ^A character, I can remove this is vi by using the following %s/^A//g (where ^A is ctrl v and control A), however when I try to sed... (1 Reply)
Discussion started by: badg3r
1 Replies

7. Shell Programming and Scripting

ksh - odd output from for command...

Help needed - I am sure there is something to do with tabs or white space that is killing me here.. I have a file that is generated from an oracle sql script - when I cat the file I see the below 601888725 14-AUG-08-10:20 3 601888726 14-AUG-08-10:37 ... (4 Replies)
Discussion started by: frustrated1
4 Replies

8. Shell Programming and Scripting

Escaping the * character in ksh.

Hi All, In ksh script i'm trying to assign "sqlstmt1" varaible value, update VAREntryTb set VAR10num = VAR1num * Mltplr where BusD = '$val1' and RunI = 1"` Hence i wrote below statement, the issue with this is shell is expanding "*" character adn thus subistuting it with the content of my... (6 Replies)
Discussion started by: arvindcgi
6 Replies

9. Shell Programming and Scripting

KSH - Character Replacement

Hey all. Easy question. I have a (ksh) varaible x. It contains the following (for example): N557788 I want to replace the "N" with a "-". I've done this before but for the life of me I cannot remember how I did it. Thanks. mtw (2 Replies)
Discussion started by: mixxamike
2 Replies

10. Shell Programming and Scripting

Newline character not working for ksh

Newline character "\n" not working for ksh in linux AS 3.0 Command : $echo "Hi\nHi" $Hi\nHi $ Expected output : $echo "Hi\nHi" Hi Hi $ Can some help me on this Thanks in advance Sanish. (11 Replies)
Discussion started by: sanikv
11 Replies
Login or Register to Ask a Question