Junk Character appended at the end of a line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Junk Character appended at the end of a line
# 1  
Old 08-26-2010
Junk Character appended at the end of a line

Hi All
I have a rather unusual problem, which i have not faced till now. I have a script which exports some paths to a text file. The script runs fine but when i check the output file i can see some junk characters ^M appended at end of lines and random places. I am not able to figure this out..

Any help would be greately appriciated...


Thanks!!!
# 2  
Old 08-26-2010
Run
Code:
dos2unix file

# 3  
Old 08-26-2010
hey thanks a lot for the reply... can you tell me how can i fix this......Smilie

Thanks!!!!
# 4  
Old 08-26-2010
Did you run "dos2unix" on your file?
This User Gave Thanks to bartus11 For This Post:
# 5  
Old 08-26-2010
If you are using linux environment, insert below line in your script
Code:
dos2unix file

If solaris, then
Code:
dos2unix file > file2
\mv file2 file

actually this problem usually occurs when you are taking some database from windows and using in linux.

Last edited by Yogesh Sawant; 08-27-2010 at 04:31 AM.. Reason: added code tags
This User Gave Thanks to nehashine For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to add a character at end of line?

Hai, I have got a small requirement in my script. and i am using bash shell. I need to add a dot (.) for some particular line in a file. Say for example, $Cat rmfile 1 This is line1 2 This is line2 3 This is line3 O/p should be : $Cat rmfile 1 This is line1 2 This is line2. #... (2 Replies)
Discussion started by: Sivajee
2 Replies

2. Shell Programming and Scripting

Adding end of line character in the last record

Need to add end of line character to last record in a fixed width file. When i take the record length of each line, for all the records it gives example like 200 except the last line as 199. Due to this my other script fails. Please help me on this. (4 Replies)
Discussion started by: Amrutha24
4 Replies

3. Shell Programming and Scripting

How to remove new line character at end of file.

I need to remove new line character from end of file. Suppose here are content. a|b|c|d|r a|b|c|d|r a|b|c|d|r <new line> that means file contains 4 lines but data is there in 3 lines. so I want that only 3 lines should be there in file. Please help (20 Replies)
Discussion started by: varun940
20 Replies

4. Shell Programming and Scripting

add character to the end of each line in file

hi all i have 32 lines in file. the length of each line is 82 , i want that in the end of each line , means in postion 83-84 to put two characters 0d(=\015), 0a(=\012) i want that the 0d will be in postion 83 and the 0a will be in postion 84 in each line of the file how shall i do it ? ... (7 Replies)
Discussion started by: naamas03
7 Replies

5. UNIX for Dummies Questions & Answers

Depending upon character at particular position, string needs to be appended

Depending upon character at particular position in a line, string needs to be appended followed by empty spaces till 256th column position at the end of the each line in the file. example: 123p4 J8769 123q4 R2345 123r4 S2345 What I Require is, it has to check at 7th column character and... (10 Replies)
Discussion started by: vaka
10 Replies

6. UNIX for Advanced & Expert Users

Deleting end of line $ character in file

Hi, I've got a file where in the middle of the record is a $ end of line character, visible only when I open the file in vi and do :set list. How to I get rid of the character in the middle and keep it at the end. The middle $ character always appears after SW, so that can be used to tag it.... (3 Replies)
Discussion started by: bwrynz1
3 Replies

7. Shell Programming and Scripting

Removing character from list line (at the end)

Hi, I have file as shown below. abc, def, abc, xyz, I have to remove ',' from end of last line (xyz,). How can I do that with single command? Is it possible or I have to iterate through complete file to remove that? - Malay (2 Replies)
Discussion started by: malaymaru
2 Replies

8. UNIX for Dummies Questions & Answers

stripping last character from end of each line

Hi, sorry for being dumb but I have a file with a variable amount of records (day to day it differs) but is fixed at 80 characters wide. Unfortunately the 80th and last charachter in each line is a "^M" carriage return character which i want to get rid of. Is there a really easy command that i can... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

9. Shell Programming and Scripting

end of the line character

How do i determine what the end of the line character is in a text file. for eg. is it \n or \f or \t etc.. Is there a unix command for this? (5 Replies)
Discussion started by: zomboo
5 Replies

10. UNIX for Dummies Questions & Answers

End of line character in BAsh

I'm trying to match the end of line character in a shell script under bash. What I have done it got is a loop that reads each line of a file into a temp variable and then I get each letter of that variable and do some work on it. One think I want to do it check if the character I checking if the... (1 Reply)
Discussion started by: Rukshan
1 Replies
Login or Register to Ask a Question