Carriage Return at end of file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Carriage Return at end of file
# 8  
Old 10-20-2006
Quote:
Originally Posted by vgersh99
Code:
sed '$d' myFile.txt

This ended up deleting the 09/30/06 line, but the blank line is still at the end of the file.

----------------------
...........
09/27/06
09/28/06
09/29/06
---{blank line}---
----------------------
# 9  
Old 10-20-2006
Then you don't have blank line in the file. Are you doing something else after SED?
# 10  
Old 10-20-2006
Quote:
Originally Posted by anbu23
Above code should work. I dont know whats happening in your case.
Try this

Code:
sed "$ d" $outdir/date.txt > temp
mv temp $outdir/date.txt


I think it's my text editor (UltraEdit) displaying the file improperly, because it I use VI there is not a lbank line. But my application is seeing a blank line also when reading this file. I'm rather confused now. I may end up manully editing the file on a monthly basis Smilie
# 11  
Old 10-20-2006
Quote:
Originally Posted by anbu23
Then you don't have blank line in the file. Are you doing something else after SED?
the only thing that happens after the sed is an echo with the date stamp so be can monitor start and end times of all our processes.
# 12  
Old 10-20-2006
you might have a '^M' as th last character on the LAST line.
try doing 'od -x' or 'cat -vet' on a file and see what you have.
# 13  
Old 10-20-2006
Quote:
Originally Posted by vgersh99
you might have a '^M' as th last character on the LAST line.
try doing 'od -x' or 'cat -vet' on a file and see what you have.
Won't a '^M' show using vi? I've come across the '^M' when files are ftp'd using the wrong mode.
# 14  
Old 10-20-2006
Quote:
Originally Posted by vgersh99
you might have a '^M' as th last character on the LAST line.
try doing 'od -x' or 'cat -vet' on a file and see what you have.
cat -vet output:

...
09/20/06$
09/21/06$
09/22/06$
09/23/06$
09/24/06$
09/25/06$
09/26/06$
09/27/06$
09/28/06$
09/29/06$
09/30/06$
$
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need Help to delete carriage return and new line in csv file

Hi All, I have a problem loading the data from a csv file As you see below in the Input ,For the Data starting with " there are 2 lines, which i want to make them into single without changing the format of that data. You can see the desired output below: While i try to open the csv file and... (4 Replies)
Discussion started by: mlavanya
4 Replies

2. Shell Programming and Scripting

Removing Carriage return in a file after particular string

Hi All, I want to remove carriage return in a file using some unix command without writing a script my file is as follows abc1 abc2 abc3 abc4 abc5 bac6 abc1 abc2 abc3 abc4 abc5 bac6 I want the output as follows: abc1 abc2 abc3 abc4 abc5 bac6 abc1 abc2 abc3 abc4 abc5 bac6 , Please... (7 Replies)
Discussion started by: manish8484
7 Replies

3. Shell Programming and Scripting

Need a carriage return at end of each line

Hi All, I am reading two files and writing out the file name and count of lines in each file to an output file. My script looks like this: echo "input_file1.out;`wc -l < input_file1.out | sed 's/^]*\(.*\)]*$/\1/'` " > comp_file1.out echo "input_file2.out;`wc -l < input_file2.out | sed... (2 Replies)
Discussion started by: Hangman2
2 Replies

4. UNIX for Advanced & Expert Users

Padding Carriage return to the end of XML file

Hi All, I am getting a xml file where the first field contains a carriage return and the all other fields doesnot contains any carriage return. So all the other records comes in the second line. <?xml version="1.0" encoding="UTF-8"?> <ns0:iSeriesCspIntegration... (3 Replies)
Discussion started by: dasj22
3 Replies

5. UNIX for Advanced & Expert Users

Issue with Removing Carriage Return (^M) in delimited file

Hi - I tried to remove ^M in a delimited file using "tr -d "\r" and "sed 's/^M//g'", but it does not work quite well. While the ^M is removed, the format of the record is still cut in half, like a,b, c c,d,e The delimited file is generated using sh script by outputing a SQL query result to... (7 Replies)
Discussion started by: sirahc
7 Replies

6. Shell Programming and Scripting

add carriage return at end of file

Hi I would like to add carriage return at end of file, because we need to mask the customer names for detailed records. Some what the file doesnot have carriage at end of line of last record.So that i 'll get 2 records when use ---aa.txt----- 1|aaa|bbb|ccc 2|bbbb|hghgh|ggg 000002 tail... (2 Replies)
Discussion started by: HAA
2 Replies

7. Shell Programming and Scripting

Removing Carriage Return and or line feed from a file

Hello I'm trying to write a shell script which can remove a carriage return and/or line feed from a file, so the resulting file all ends up on one line. So, I begin with a file like this text in file!<CR> line two!<CR> line three!<CR> END!<CR> And I want to end up with a file... (1 Reply)
Discussion started by: tbone231
1 Replies

8. UNIX for Dummies Questions & Answers

Remove a carriage return at end of variable

Is there a command in unix to remove a carriage return character(^M) at the end of a variable value? (5 Replies)
Discussion started by: flagship99
5 Replies

9. UNIX for Dummies Questions & Answers

Removing carriage return characters from file

Hello there, I need to remove carriage return characters (\n and \r) from any input file specified. This is what I am doing right now: - dumping the file to octal format using the command 'od -c file_name - removing and \s and \n characters using sed commands What I need to do now is... (3 Replies)
Discussion started by: b1saini
3 Replies

10. Shell Programming and Scripting

Regex to pick up name from the following including carriage return at end of the line

has anyone got any suggestions how i would pick up the string as part of a substitution inclusive of the carriage return. ie i want to pick up <<NAME>> from the PS output but the <<; seems to be on the line before the NAME. Any ideas are appreciated! ... (3 Replies)
Discussion started by: Shakey21
3 Replies
Login or Register to Ask a Question