Check if last char in a line is '.' and if not, insert it


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Check if last char in a line is '.' and if not, insert it
# 8  
Old 07-26-2010
Can you post the output of:
Code:
head -2 your_file | od -An -t a

Please use code tags!
This User Gave Thanks to Franklin52 For This Post:
# 9  
Old 07-26-2010
I'm using putty also.

I did not know about that, very handy.


Code:
head -2 your_file | od -An -t a


Last edited by Ikon; 07-26-2010 at 04:00 PM..
# 10  
Old 07-26-2010
Hi, I get a parsed output of the letters when I use that code. What is the code supposed to do?

Really appreciate you guys' help, I'm a real newbie with UNIX.
# 11  
Old 07-26-2010
He wants to see if there are any special characters in your file causing the odd output. Please post the output.
# 12  
Old 07-26-2010
This is the output I get:

Code:
 s   n   a   v   0   0   0   1  ht   M   i   k   e  sp   S   m
   i   t   h  sp   l   i   v   e   s  sp   o   n  sp   1   3   5
   9  sp   T   u   r   n   e   r  sp   A   v   e   n   u   e   .
  ht   m   i   k   e  sp   s   m   i   t   h  sp   l   i   v   e
   s  sp   o   n  sp   t   h   i   r   t   e   e   n  sp   f   i
   f   t   y   -   n   i   n   e  sp   t   u   r   n   e   r  sp
   a   v   e   n   u   e   .  cr  nl   s   n   a   v   0   0   0
   2  ht   D   a   v   i   d  sp   M   i   l   l   e   r  sp   l
   i   v   e   s  sp   o   n  sp   2   4   6   8  sp   O   c   e
   a   n  sp   B   o   u   l   e   v   a   r   d   .  ht   d   a
   v   i   d  sp   m   i   l   l   e   r  sp   l   i   v   e   s
  sp   o   n  sp   t   w   e   n   t   y   -   f   o   u   r  sp
   s   i   x   t   y   -   e   i   g   h   t  sp   o   c   e   a
   n  sp   b   o   u   l   e   v   a   r   d   .  cr  nl

# 13  
Old 07-26-2010
Looks like a dos/win file, remove the CR's first with tr, try this:
Code:
tr -d '\r' < file | sed 's/[,.]*$/./'

This User Gave Thanks to Franklin52 For This Post:
# 14  
Old 07-26-2010
Thank you! I used Franklin's cleanup code and then both of your codes worked! Many many thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search a certain char and insert new text if a match found

Have a file which has the create statement like below create table emp ( empno integer, empname char(50)) primary index(empno); i need to find a string starting with create and ends with semi-colon ;. if so insert the below statement before create statement rename table emp to emp_rename;... (2 Replies)
Discussion started by: Mohan0509
2 Replies

2. Shell Programming and Scripting

How to read a text file line by line and insert into a database table?

I have a test file that I want to read and insert only certain lines into the the table based on a filter. 1. Rread the log file 12 Hours back Getdate() -12 Hours 2. Extract the following information on for lines that say "DUMP is complete" A. Date B. Database Name C.... (2 Replies)
Discussion started by: JolietJake
2 Replies

3. Shell Programming and Scripting

How to separate one line to mutiple line based on one char?

Hi Gurus, I need separate one file which is one huge line to mutiple line. file like abcd # bcd # def # fge # ged I want to get abcd bcd def fge ged Thanks in advance (4 Replies)
Discussion started by: ken6503
4 Replies

4. Shell Programming and Scripting

Formatting File having big single line into 95 Char Per Line

Hi All, I have 4 big files which contains one big line containing formatted character records, I need to format each file in such way that each File will have 95 Characters per line. Last line of each file will have newline character at end. Before:- File Name:- File1.dat 102 121340560... (10 Replies)
Discussion started by: lancesunny
10 Replies

5. Shell Programming and Scripting

Insert carriage return on the 10th char position of each line

Hi experts, Need your help on how to insert carriage return after the 10th char position of each line in a file and then add two blank spaces after the carriage return. Example: >cat test.txt testingline dummystring samplesample teststringline Expected output should be.. ... (2 Replies)
Discussion started by: brichigo
2 Replies

6. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

7. Shell Programming and Scripting

how first char in odd line and second char in even line

Hi I m having ifconfig -a o/p like sbanlab1:ksh# ifconfig -a | egrep "flags|inet" | awk -F' ' '{print $1,$2}' lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> inet 127.0.0.1 lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> inet 127.0.0.1 bge0:... (1 Reply)
Discussion started by: tarunn.dubeyy
1 Replies

8. Shell Programming and Scripting

How to insert a char in every two?

Hi, I've written a script to interrogate all fibre devices on our systems and output the WWNs to a file. I now want to insert a ":" every 2 characters into the WWN so I can write another script to create aliases within the SAN. So the current file has WWNs in the following format;... (2 Replies)
Discussion started by: h8mmer
2 Replies

9. UNIX for Dummies Questions & Answers

unable to insert '#' char for a file in vi mode

Hi all, I am very new to this forum and also new to UNIX. I am working on HP-UX machine. I noticed that for some of the users I am unable to insert the # character in a file in vi mode. May I know y am I having the problem and how can I resolve this Thanks, Maroli (1 Reply)
Discussion started by: maroli
1 Replies

10. Shell Programming and Scripting

How to check a column contain numeric or char data type ??

I have a file called clientname_filename.csv whose contents are like col1|col2|col3|col4| 510|abc|xxx|450| 510|abc11|yyy|350 510|pqr99|zzz| 670 512|222|439|110 Here i have check the contents of column for data type. i have a constraints that col1 always contain Numeric value column 2... (12 Replies)
Discussion started by: jambesh
12 Replies
Login or Register to Ask a Question

Featured Tech Videos