Need a carriage return at end of each line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need a carriage return at end of each line
# 1  
Old 10-21-2010
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/^[[:space:]]*\(.*\)[[:space:]]*$/\1/'` " > comp_file1.out
echo "input_file2.out;`wc -l < input_file2.out | sed 's/^[[:space:]]*\(.*\)[[:space:]]*$/\1/'` " >> comp_file1.out


I have another file sent by user which has carriage return (^M) at end. So I have to compare the output of my file to user file.

user file looks like this:
input_file1.out;100^M
input_file2.out;200^M

and my output file looks like this:
input_file1.out;100CTRL_CHAR

input_file2.out;200CTRL_CHAR


So what is another way to count the number of lines and display the output as??

input_file1.out;100^M
input_file2.out;200^M

Thanks
# 2  
Old 10-21-2010
Code:
tr -d '\r' < windows.txt > usable.txt

voila, no more carriage returns.



---------- Post updated at 04:59 PM ---------- Previous update was at 04:55 PM ----------




Also, you can make your line counting script much simpler.
Code:
echo "${FILENAME};$(wc -l < ${FILENAME})"

[edit] scratch my second solution, it adds a silly 'total' line to the end.

Last edited by Corona688; 10-21-2010 at 08:11 PM..
# 3  
Old 10-21-2010
MySQL

I think that would work.

Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

line carriage return characters

Hi, I would like to insert the line carriage retrun characters on each line. (2 Replies)
Discussion started by: koti_rama
2 Replies

2. Shell Programming and Scripting

Bash - multiple line carriage return

Hello! I have one strange question - let's say I have a long, multiple-line string displayed on the terminal using echo, and I would like to make a carriage return to the beginning of this string, no to the beginning of the last line - is something like that possible? I would like to be able to... (1 Reply)
Discussion started by: xqwzts
1 Replies

3. 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

4. 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

5. UNIX for Dummies Questions & Answers

To remove carriage return between the line

Hi, I have a situation where I need to remove the carriage return between the lines. For.eg. The input file: 1,ad,"adc sdfd",edf 2,asd,"def fde",asd The output file should be 1,ad,adc sdfd,edf 2,asd,def fde,asd Thanks Shash (5 Replies)
Discussion started by: shash
5 Replies

6. Shell Programming and Scripting

Carriage Return at end of file

Hi, I have a script that outputs a file that contains the dates from the previous month, which is then used by our application to run processes on each date contained in the file. My problem is is that my script created a blank line at the bottom of the file which causes issues for our... (14 Replies)
Discussion started by: bd_joy
14 Replies

7. Shell Programming and Scripting

How to insert carriage return before line feed?

I am doing some edi where translations had to be run on unix. Generally when I run the translations on windows, the output file has both carriage returns and line feed where as when ran on unix will have only line feed. I need to insert carriage return before the line feed. Is there some tool... (2 Replies)
Discussion started by: huey ing
2 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. Shell Programming and Scripting

carriage return/line feeds

Hello, I have a file that has got carriage returns in it and I want to take them out. Anyone know how I can do this in a ksh? thanks (4 Replies)
Discussion started by: pitstop
4 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