Adding new line character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding new line character
# 1  
Old 05-23-2012
Adding new line character

Hi All,

i am taking end of records using tail command got the out is "END OF FILE. ROW COUNT: 10"
and record count in the file is 3. while append the both data into test2.txt file,it's append like

Code:
END OF FILE. ROW COUNT: 108

my output should be in the test2.txt file

Code:
 END OF FILE. ROW COUNT: 10,8

i tried like...
Code:
tail -1 test1.txt > test2.txt;
wc -l test1.txt| awk '{print $1-1}' >>test2.txt;

Please help me..

Thanks,
# 2  
Old 05-23-2012
What are you trying to achieve? Do you want last line and no of line of test1.txt ?
# 3  
Old 05-23-2012
While appending the second command using wc to add ",8 " it means record count of the file
Code:
 END OF FILE. ROW COUNT: 10,8

# 4  
Old 05-23-2012
Do you mean this?

Code:
awk 'END{print $0,NR}' OFS=, test1.txt

# 5  
Old 05-23-2012
yes,how to add the file count to after tailing...

---------- Post updated at 06:02 AM ---------- Previous update was at 05:58 AM ----------

Thanks got... it's working fine.. i need one more while taking the file count it is blank lines.. how to exclude...
# 6  
Old 05-24-2012
i tried with huge file as given command it' not working...if we tried with big file working fine.
Code:
awk 'END{print $0,NR}' OFS=, test1.txt

if it is big file
Code:
 ,1326543

but end of file record as like
Code:
 END OF FILE. ROW COUNT: 1326542

i am excepting is

Code:
 END OF FILE. ROW COUNT: 1326542,1326543

Thanks lot...
# 7  
Old 05-24-2012
Post the output of last 10 lines of the BIG file.
Code:
tail BIG_file

Also, Are you sure the BIG file is a valid unix file. (doesn't contain invalid \r)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read character by character in line in which space is also included

Hi friend, I have one file , and i want to read that file character by character. I need this script in ksh. while using read option with -n1 am getting error. while read -n1 c read has bad option And if i am using below script, then if in a line has space like this ( Pallvi mahajan)... (10 Replies)
Discussion started by: pallvi_mahajan
10 Replies

2. Shell Programming and Scripting

Adding a character

Hello experts. I trying to achieve 2 things here. I'm trying to convert all of the host names to lower case and add an "m" to each hostname. Can anyone provide some guidance on what I can do? Your input is greatly valued! Here are the desired results: 1. read the host name from a file. 2.... (8 Replies)
Discussion started by: david_tech
8 Replies

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

4. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

5. Shell Programming and Scripting

Fill the empty line by adding line before blank line

FIle A "A" 2 aa 34 3 ac 5 cd "B" 3 hu 67 4 fg 5 gy output shud be A"" 2 aa 34 "A" 3 ac 34 "A" 5 cd 34 "B" 3 hu 67 "B" 4 fg 67 "B" 5 gy 67 (6 Replies)
Discussion started by: cdfd123
6 Replies

6. UNIX for Dummies Questions & Answers

Adding a character

Hi, I cant seem to figure out how I add a character to an existing one. Heres my problem. So I have a line that looks like this: >56 584848392394958586858484849393 What I want to do is add Num in front of the 56. So basically I want to recognize the > and add Num in front of the... (6 Replies)
Discussion started by: kylle345
6 Replies

7. Shell Programming and Scripting

Adding a special character at the end of the line

I used following to add * at the end of the line in file1. It adds * at the end but has a space before it for some lines but some other lines it adds exactly after the last character. How do I take out the space ? sed 's/$/*/' file1 > file2 example: contents of file1 : ... (2 Replies)
Discussion started by: pitagi
2 Replies

8. Shell Programming and Scripting

adding a character in front of a line

Hi everyon, I am trying to search for a pattern in a file and add "//" to the begining of the file. lets say i want to comment out a line from my codes. the line that should be commented out contains the word "reset". i need to search for the word "reset" and comment out that specific line. is... (5 Replies)
Discussion started by: ROOZ
5 Replies

9. Shell Programming and Scripting

Adding CTRL-M Character

Hi, I have file generated in HP-UNIX environment (for Example) with the line feed (i.e $): a$ b$ C$ Now, I need to append CTRL-M character at the end of each line, but the last line of the file should not have both CTRL-M and Line Feed (i.e ^M and $). The file should look like: a^M$ b^M$... (2 Replies)
Discussion started by: mohan.nadaraja
2 Replies

10. Shell Programming and Scripting

Adding a character in the beginning of every line in a .dat file

How can i add a character(#) in the beginning of every line in a .dat file (2 Replies)
Discussion started by: Cool Coder
2 Replies
Login or Register to Ask a Question