Visit Our UNIX and Linux User Community


^M character in the log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ^M character in the log file
# 1  
Old 06-06-2011
^M character in the log file

Hi ..

when i am running the following simple script, i am getting the log file as ""test1.log?"", there is a ^M charater. I dont know why it is generating like that.

when i tried to replace the ^M character, it is saying there is no pattern like that.
:%/ctrlV ctrlM//g (pattern not found).

Can anyone suggest me how can i get rid of that charater?

Code:
TEST_VAR='HELLO WORLD'
PROC='testproc'
sqlplus apps/sup3rm5n@fmsdev3 << EOF > test1.log
set serveroutput on size 200000
whenever sqlerror continue
set echo on
exec dbms_output.put_line('$TEST_VAR');
exit;
EOF



Last edited by vgersh99; 06-06-2011 at 04:18 PM..
# 2  
Old 06-06-2011
Apparently sqlplus is giving you DOS style line breaks, and the ^M is a carriage return character, octal 15 or hex 0x0D. If you cannot convince sqlplus to use just linefeed, you can remove it by piping through tr:
Code:
sqlplus . . .  <<EOF | tr -d '\15' > test1.log

# 3  
Old 06-06-2011
Hi DGpickett..

Thanks for the reply..
Its not about the content of the file..but the file name isgetting created like ""test1.log?""

Thanks
# 4  
Old 06-06-2011
Please copy/paste (using code tags) the output of cat -vet yourScriptFile.
Are you by any chance editing the script file under Windows and transferring the file to UNIX with ftp?
# 5  
Old 06-06-2011
Yes, the > shell has no tendency to add ^M to a file name.
# 6  
Old 06-06-2011
output of cat -vet yourScriptFile
Code:
echo ' '^M$
echo 'ODS to Stage Synch job started ' ^M$
date^M$
echo ' '^M$
#|---------------------------------------------------------------------^M$
#| Step 1: Execute the procedure.^M$
#|---------------------------------------------------------------------^M$
PROC='OS2STG_JOB'^M$
PKG='SYNCH_JOBS'^M$
TEST_VAR='HELLO WORLD'^M$
sqlplus username/password2dbid << EOF > $LOG_DIR/$PROC.sql.log^M$
set serveroutput on size 200000^M$
whenever sqlerror continue^M$
set echo on^M$
exec dbms_output.put_line('$TEST_VAR');^M$
exit;^M$
EOF^M$




---------- Post updated at 03:43 PM ---------- Previous update was at 03:39 PM ----------

when i try to remove those character with the following command..

:%/ctrlV ctrlM//g (pattern not found).

it is showing pattern not found

---------- Post updated at 03:45 PM ---------- Previous update was at 03:43 PM ----------

"""Are you by any chance editing the script file under Windows and transferring the file to UNIX with ftp?"""

Yes.. i am using ""reflection"" for transferring files.. (but the transfer mode is in "ASCII")
# 7  
Old 06-06-2011
The dos2unix (also: dos2ux) command is designed to get rid of the windows carriage returns in a file. ^M is part of windows/dos carriage control.

Previous Thread | Next Thread
Test Your Knowledge in Computers #736
Difficulty: Medium
In 1982, Commodore introduced the Commodore 64 as the successor to the VIC-20.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies

2. Shell Programming and Scripting

File character adjustment based on specific character

i have a reqirement to adjust the data in a file based on a perticular character the sample data is as below 483PDEAN CORRIGAN 52304037528955WAGES 50000 89BP ABCD MASTER352 5434604223735428 4200 58BP SOUTHERN WA848 ... (1 Reply)
Discussion started by: pema.yozer
1 Replies

3. Shell Programming and Scripting

read the text file and print the content character by character..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... without using... (1 Reply)
Discussion started by: samupnl
1 Replies

4. Shell Programming and Scripting

Breaking a file into three new files, character by character

I am new to shell scripting, and need a script to randomly distribute each character from a file into one of three new files. I also need each character to maintain it's position from the original file in the new file (such that if a character is written to File 1, Files 2 and 3 have spaces... (10 Replies)
Discussion started by: foxcastle
10 Replies

5. Shell Programming and Scripting

How to read character by character in a file

Hi, How read character by character from a file . and i need replace '.' with null if it comes as a 5 character i am beginner ...please help me (1 Reply)
Discussion started by: kartheek
1 Replies

6. Shell Programming and Scripting

Deleting all characters from 350th character to 450th character from the log file

Hi All, I have a big log file i want to delete all characters (between 350th to 450th characters) starting at 350th character position to 450th character position. please advice or sample code. (6 Replies)
Discussion started by: rajeshorpu
6 Replies

7. Shell Programming and Scripting

Can I read a file character by character?

Hello all respected people, Can i read a file character by character without using sed,awk and perl commands. Thanks in advance. (4 Replies)
Discussion started by: murtaza
4 Replies

8. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies

9. AIX

check for a particular character inside a file and substitute with a given character?

i am a newbie to shell script,so i want a kshell script in which i need to check for a particular character inside a file through conditional looping(like if ,case,while)and if that character exists ,then substitute a given character to that character. consider a file test.txt,inside the file... (1 Reply)
Discussion started by: karthikprasathk
1 Replies

10. Shell Programming and Scripting

Can i read a file character by character

How to read character by character using awk (6 Replies)
Discussion started by: karnan
6 Replies

Featured Tech Videos