Splitting number (no delimiter)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Splitting number (no delimiter)
# 1  
Old 03-05-2013
Splitting number (no delimiter)

Hi !

here is my data file column 1 fields

Code:
2597
121297
13599
130498

want to print like this

Code:
02/05/1997
12/12/1997
13/05/1999
13/04/1998

how to split each field and print in correct way

if there was delimiter I would have done some thing like this
Code:
awk '{split($0,a,":"); print a[1], a[2], a[3]}'


Last edited by Scrutinizer; 03-05-2013 at 09:24 AM..
# 2  
Old 03-05-2013
What about below date format it can be written as either ways..

Code:
11198

11/01/1998

01/11/1998

# 3  
Old 03-05-2013
So, would 21297 be equal to 02/12/1997 or 21/02/1997 ?
# 4  
Old 03-05-2013
I think all fields in file are coded in
Code:
DayMonthYear

format as I know, what you both said is right pamu and Scrutinizer
# 5  
Old 03-05-2013
The order of day and month is not the issue here, the issue is: in case of a 5-digit number is the second digit part of the day or of the month . It seems this crucial bit of information was lost.
# 6  
Old 03-05-2013
if 21297
then I will consider 02 - 12 -1997

if 22297 22-02-1997
# 7  
Old 03-05-2013
This will not help

If 22297 = 22-02-1997
Why is not 21297 = 21-02-1997???
ond if not how do you think 21-02-1997 should look in your table.

Why do you have this output?
Can you fix the source?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert a new column with sequence number (Delimiter as comma)

Hi All, I have a file which has data like a,b c,d e,f g,h And I need to insert a new column at the begining with sequence no( 1 to n) 1,a,b 2,c,d 3,e,f 4,g,h Please let me know how to acheive this in unix (3 Replies)
Discussion started by: weknowd
3 Replies

2. UNIX for Dummies Questions & Answers

Splitting strings based on delimiter

i have a snippet from server log delimited by forward slash. /a/b/c/d/filename i need to cut until last delimiter. So desired output should look like: /a/b/c/d can you please help? Thanks in advance. (7 Replies)
Discussion started by: alpha_1
7 Replies

3. UNIX for Advanced & Expert Users

Inserting delimiter after a specific number of chars

Hello guys, I have a problem where I need to add a delimiter, that can be | for example, after each 28000 chars. The problem is that sometimes 1 row, which should contain 28000 chars is split in 2, so I want to put the delimiter after each 28000 so I will know the end of each row. Please... (2 Replies)
Discussion started by: Diogo R Jesus
2 Replies

4. UNIX for Dummies Questions & Answers

Splitting the file basis of Line Number

Can u pls advise the unix command as I have a file which contain the records in the below format 333434 435435 435443 434543 343536 Now the total line count is 89380 , now i want to create a separate I am trying to split my large big file into small bits using the line... (2 Replies)
Discussion started by: punpun66
2 Replies

5. Shell Programming and Scripting

Splitting a file based on line number

Hi I have a file with over a million lines (rows) and I want to split everything from 500,000 to a million into another file (to make the file smaller). Is there a simple command for this? Thank you Phil (4 Replies)
Discussion started by: phil_heath
4 Replies

6. Shell Programming and Scripting

Splitting records in a text file based on delimiter

A text file has 2 fields (Data, Filename) delimited by # as below, Data,Filename Row1 -> abc#Test1.xml Row2 -> xyz#Test2.xml Row3 -> ghi#Test3.xml The content in first field has to be written into a file where filename should be considered from second field. So from... (4 Replies)
Discussion started by: jayakkannan
4 Replies

7. Shell Programming and Scripting

Counting number of records with string row delimiter

HI, i have a file like this t.txt f1|_f2|_ f1|_f2|_ f1|_f2|_ as if col delimiter is |_ and row delimiter |_\n trying to count number of records using awk $ awk 'BEGIN{FS="|_" ; RS="~~\n"} {n++}END{print n} ' t.txt 7 wondering how can i count this to 3 ? thx (9 Replies)
Discussion started by: aksforum
9 Replies

8. Shell Programming and Scripting

Splitting file based on number of rows

Hi, I'm, new to shell scripting, I have a requirement where I have to split an incoming file into separate files each containing a maximum of 3 million rows. For e.g: if my incoming file say In.txt has 8 mn rows then I need to create 3 files, in which two will 3 mn rows and one will contain 2... (2 Replies)
Discussion started by: wahi80
2 Replies

9. Shell Programming and Scripting

Cut Number which appear before a delimiter

Hi All, How can i use the cut option to only output the number of rows, which is 2 is this case ? Pls note that the number of digit before the delimiter ":" is always varying. $ grep -n uuu xxx 2:** xxx yyy gg 44 tt uuu 2007 $ (2 Replies)
Discussion started by: Raynon
2 Replies

10. Shell Programming and Scripting

splitting file with more than one delimiter

Hi, I just wandering how to split a record which has more than one delimiter, i have a file which contains pattern as group separtor and ~ as field separtor, Ultimately I need consider even the groups as a field, So i need to make this multi-delimited file into ~ delimited file. My record... (4 Replies)
Discussion started by: braindrain
4 Replies
Login or Register to Ask a Question