Hope to create a file with two large column, with several numbers


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Hope to create a file with two large column, with several numbers
# 1  
Old 03-28-2013
Hope to create a file with two large column, with several numbers

I hope to create a file made up of 2 columns
- first column print out number 0~61000 every 50 of it
- second column just contains 0
delineated by space

such as
Code:
0 0
50 0
100 0
150 0
200 0
...
60900 0
60950 0
61000 0

Which command should I need to use? I think I might need to use awk command, but I'm not sure how can I create group of numbers 0~61000.
# 2  
Old 03-28-2013
Code:
awk '
BEGIN {
        i = 0
        while ( i <= 61000 )
        {
                print i, 0
                i += 50
        }
} '

This User Gave Thanks to Yoda For This Post:
# 3  
Old 03-28-2013
I suggest a slight change:

Code:
awk '
BEGIN {
        i = 0
        while ( i <= 61000 )
        {
                print i, 0
                i += 50
        }
} ' /dev/null

...so it doesn't wait trying to read from the terminal after.
This User Gave Thanks to Corona688 For This Post:
# 4  
Old 03-28-2013
Quote:
Originally Posted by Corona688
I suggest a slight change:

Code:
awk '
BEGIN {
        i = 0
        while ( i <= 61000 )
        {
                print i, 0
                i += 50
        }
} ' /dev/null

...so it doesn't wait trying to read from the terminal after.
Corona688, that is not necessary since the action is inside the BEGIN rule.
This User Gave Thanks to Yoda For This Post:
# 5  
Old 03-28-2013
You are right. I thought awk would still try to read stdin, but apparently it does not when there is a BEGIN section and no other section. Interesting.
This User Gave Thanks to Corona688 For This Post:
# 6  
Old 03-28-2013
Code:
seq 0 50 61000 | sed 's/$/ 0/'

This User Gave Thanks to hanson44 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Search spaces in 5th column in large file

i have a file having 5 columns with more than million records. And i want to search using UNIX command to find if there are any spaces in 5th column. any please help. (1 Reply)
Discussion started by: sivakumar.p
1 Replies

2. Shell Programming and Scripting

Use awk to replace numbers in a file with a column from another file

Hello, I am trying to make a awk code that will take 2 files, a txt file like this : 1 1 88 c(1:38, 42, 102) 2 2 128 c(39:41, 43:101, 103:105, 153, 155:189, 292, 344:369) 3 3 84 c(190:249, 603, 606:607, 609:629) 4 4 12 ... (8 Replies)
Discussion started by: nastaziales
8 Replies

3. Shell Programming and Scripting

Create file with name first column name.

Hi please help me in resolving the scenario. Source File: col1 col3 ----- ----- file1 data1 file2 data2 file1 data3 file3 data4 file5 data5 .. ... .... and so on. Result should be:4 files created. first file, file1.txt (no need to worry about .txt extension) will... (1 Reply)
Discussion started by: maks475
1 Replies

4. UNIX for Dummies Questions & Answers

Adding a column to a text file with row numbers

Hi, I would like to add a new column containing the row numbers to a text file. How do I go about doing that? Thanks! Example input: A X B Y C D Output: A X 1 B Y 2 C D 3 (5 Replies)
Discussion started by: evelibertine
5 Replies

5. Shell Programming and Scripting

Split a file into multiple files based on line numbers and first column value

Hi All I have one query,say i have a requirement like the below code should be move to diffent files whose maximum lines can be of 10 lines.Say in the below example,it consist of 14 lines. This should be moved logically using the data in the fisrt coloumn to file1 and file 2.The data of first... (2 Replies)
Discussion started by: sarav.shan
2 Replies

6. UNIX for Dummies Questions & Answers

Appending a column of numbers in ascending order to a text file

I have a text file where I want to append a column of numbers in ascending orders. Input: 57 abc 25 def 32 ghi 54 jkl Output:57 abc 57 abc 1 25 def 2 32 ghi 3 54 jkl 4 How do I go about doing that? Thanks! (11 Replies)
Discussion started by: evelibertine
11 Replies

7. Shell Programming and Scripting

Replace 2nd column of CSV file with numbers on line

I have a csv file with occasional multiple entries in the second column. 111111,104,07-24-2011,3.15,N, 222222,020 140,07-24-2011,10.00,N,I want the result 111111,104,07-24-2011,3.15,N, 222222,020,07-24-2011,10.00,N, 222222,140,07-24-2011,10.00,N, I know I can get the output of the second... (5 Replies)
Discussion started by: ffdstanley
5 Replies

8. Shell Programming and Scripting

Perl verify if numbers in a column of a file are in sequence

I am just a newbie to perl scripting. I need help with listing of hexadecimal numbers in a column as follows. INPUT FIle: 08AF ship steel 08B0 ship steel 08B1 ship steel 08B2 flight docs 08B3 flight docs 08B4 flight docs 08B5 flight docs 08B6 flight decl ... (3 Replies)
Discussion started by: dynamax
3 Replies

9. Shell Programming and Scripting

Split large file based on last digit from a column

Hello, What's the best way to split a large into multiple files based on the last digit in the first column. input file: f 2738483300000x0y03772748378831x1y13478378358383x2y23743878383802x3y33787828282820x4y43748838383881x5y5 Desired Output: f0 3738483300000x0y03787828282820x4y4 f1... (9 Replies)
Discussion started by: alain.kazan
9 Replies

10. UNIX for Dummies Questions & Answers

Create file with column values

Hi, I have a data file looks like the following ID STARTDATE ENDDATE 101 20090520 20090521 102 20090521 20090522 103 20090522 20090523 104 20090523 20090524 105 20090524 20090525 106 20090525 20090526 107 ... (3 Replies)
Discussion started by: naveen.kuppili
3 Replies
Login or Register to Ask a Question