Last line gets deleted


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Last line gets deleted
# 1  
Old 04-10-2012
Last line gets deleted

I was using the following option to clean up the ^M characters in a file that was FTPed from Windows:
- dos2unix
- sed 's/^M//g'

The ^M characters are removed but the last line is also getting removed. Any idea why this is happening.

Satish
# 2  
Old 04-10-2012
Perhaps the last line didn't have a newline at all? That will interfere with some unix tools, many of which expect entire lines.

tr doesn't care about lines, though, so try this:

Code:
tr -d '\r' < inputfile > newfile
echo >> newfile

# 3  
Old 04-10-2012
Thank you. That was the isssue.
This User Gave Thanks to vskr72 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Linux

Need help with deleted files

Hello. I am having a problem and I was wondering if I could get some help from here. I changed into a directory with the cd command and I wanted to delete a folder and all of its subdirectories, so I went ahead and did a rm --recursive * in my current directory to realize that I was in the wrong... (3 Replies)
Discussion started by: jonnydadesigner
3 Replies

2. Shell Programming and Scripting

Replace pattern with deleted line?

If I have this: perl -pne 's/img_onload.{8}//g' How would I do to instead of replacing img_onload.{8} with "nothing", get "nothing" to be a deleted line? Kind of the opposite to \n. (2 Replies)
Discussion started by: KidCactus
2 Replies

3. Shell Programming and Scripting

Last column is getting deleted

Hi, I am having a problem in the below code:-. $ cat x.csv baseball,NULL,8798765,Most played,0,5,12367,NULL,NULL,98,67,Reason is not sufficient baseball,NULL,8928192,Most played,0,4,76893,NULL,RAW,54,78,Reason is not sufficient baseball,NULL,5678945,Most played,9,2,1,6,NULL,6789,123,Reason... (4 Replies)
Discussion started by: scripter12
4 Replies

4. UNIX for Advanced & Expert Users

deleted all files - rm *

Hi All, I am using Fedora Core and Windows Xp. I deleted all the files from root directory. When i am trying to restart the computer it showing some grub > prompt. What i will do ? I have lots of data in XP OS. Please help me i used # rm * (8 Replies)
Discussion started by: pritish.sas
8 Replies

5. UNIX for Dummies Questions & Answers

deleted /usr

I accidentally deleted the usr on/. How can I start the server again? (5 Replies)
Discussion started by: rahmantanko
5 Replies

6. AIX

spam deleted

edit by bakunin: We do not like spammed advertisements - not even spammed job advertisements. Contact the Boardadmin Neo for information about legal advertisement opportunities here. -thread closed- (0 Replies)
Discussion started by: SGReddy
0 Replies

7. Shell Programming and Scripting

sed problem - last line of file deleted

Hi, I am simply trying to remove the header row from a file using sed, but I'm running into strange difficulties. It seems that in addition to removing the first line, this command is also removing the last line (or more specifically, clearing the last line, since the line is still counted... (4 Replies)
Discussion started by: erichpowell
4 Replies

8. Post Here to Contact Site Administrators and Moderators

Where the [deleted] did my post go?

Hi All! What on Earth happened to my original post in this forum? ("Can't signup with certain e-mail addresses?") It was up until about a day ago and now it's disappeared! If it was deleted, an explanation would be appreciated - it didn't break any T&Cs as far as I can tell. Farewell... >>... (3 Replies)
Discussion started by: CyberDAEMON
3 Replies

9. UNIX for Dummies Questions & Answers

Deleted /etc/passwd

Hi all, While playing with my LINUX machine i accidently deleted a file name called /etc/passwd . Even though the system is booted am unable to get the login prompt. Is there any remedy for this problem.:( (5 Replies)
Discussion started by: cyno
5 Replies
Login or Register to Ask a Question