Sponsored Content
Full Discussion: Give name for every nth line
Top Forums UNIX for Dummies Questions & Answers Give name for every nth line Post 302724599 by Amanda Low on Thursday 1st of November 2012 01:37:05 AM
Old 11-01-2012
Give name for every nth line

Hi all,

Greetings. I am facing some troubles and hope that the professionals here could help me.

I am handling a large dataset, and part of it is like below:

Code:
1	ab139	0	752566	G	A
1	ab151	0	846808	T	C
1	ab142	0	854250	G	A
1	ab061	0	861808	A	G
1	ab043	0	873558	T	G
1	ab034	0	882033	A	G
1	ab395	0	888659	T	C
1	ab608	0	891945	A	G
1	ab100	0	894573	G	A
1	ab109	0	903104	T	C
1	ab981	0	904165	A	G
1	ab682	0	918384	G	T
2	ab293	0	112433668	T	C
2	ab204	0	112435483	C	T
2	ab331	0	112437140	A	G
2	ab691	0	112444459	T	G
2	ab104	0	121202941	C	T
2	ab107	0	121203511	T	C
2	ab029	0	121214402	T	C
2	ab988	0	121214469	T	G
2	ab666	0	121216828	T	G
2	ab422	0	121217568	A	G
3	ab555	0	63754993	G	T
3	ab443	0	63779288	C	T
3	ab332	0	63785436	C	T
3	ab991	0	63788331	G	A
3	ab111	0	63811369	A	C
3	ab698	0	63824453	T	C
3	ab327	0	63838796	G	A
3	ab570	0	63842062	A	G
3	ab110	0	72360478	T	C
3	ab991	0	72361951	G	A
3	ab867	0	72382471	A	G
3	ab117	0	72386350	A	G
3	ab101	0	72387348	G	A
3	ab871	0	72387926	T	C

How can I add an indicator after 5 lines like the output below?
Code:
1	ab139	0	752566	G	A	Fr1.1
1	ab151	0	846808	T	C	Fr1.1
1	ab142	0	854250	G	A	Fr1.1
1	ab061	0	861808	A	G	Fr1.1
1	ab043	0	873558	T	G	Fr1.1
1	ab034	0	882033	A	G	Fr1.2
1	ab395	0	888659	T	C	Fr1.2
1	ab608	0	891945	A	G	Fr1.2
1	ab100	0	894573	G	A	Fr1.2
1	ab109	0	903104	T	C	Fr1.2
1	ab981	0	904165	A	G	Fr1.3
1	ab682	0	918384	G	T	Fr1.3
2	ab293	0	112433668	T	C	Fr2.1
2	ab204	0	112435483	C	T	Fr2.1
2	ab331	0	112437140	A	G	Fr2.1
2	ab691	0	112444459	T	G	Fr2.1
2	ab104	0	121202941	C	T	Fr2.1
2	ab107	0	121203511	T	C	F2.2
2	ab029	0	121214402	T	C	F2.2
2	ab988	0	121214469	T	G	F2.2
2	ab666	0	121216828	T	G	F2.2
2	ab422	0	121217568	A	G	F2.2
3	ab555	0	63754993	G	T	Fr3.1
3	ab443	0	63779288	C	T	Fr3.1
3	ab332	0	63785436	C	T	Fr3.1
3	ab991	0	63788331	G	A	Fr3.1
3	ab111	0	63811369	A	C	Fr3.1
3	ab698	0	63824453	T	C	Fr3.2
3	ab327	0	63838796	G	A	Fr3.2
3	ab570	0	63842062	A	G	Fr3.2
3	ab110	0	72360478	T	C	Fr3.2
3	ab991	0	72361951	G	A	Fr3.2
3	ab867	0	72382471	A	G	Fr3.3
3	ab117	0	72386350	A	G	Fr3.3
3	ab101	0	72387348	G	A	Fr3.3
3	ab871	0	72387926	T	C	Fr3.3

Can sed/awk do this? Please help me, your comments are very much appreciated. Thank you very much for your kind helps in advance.

Best wishes,
Amanda
(Is x86_64 GNU/Linux)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get Nth record from last line

I have a growing file . I knew only last few lines which is constant for evey job run. I'd need to pull the Nth record from the last line. In this case i should not use search pattern. (2 Replies)
Discussion started by: ford2020
2 Replies

2. Shell Programming and Scripting

Read last word of nth line

Hi people; i want to read the last word of the 14th line of my file1.txt. Here is the EXACT 14th line of the file. 250 SectorPortnum=3,AuxPortInUngo=2,PortDeviceGroup=1,PortDeviceSet=1,PorDevice=1 20 >>> Set. i have to get the word Set. how can i call it and also how... (3 Replies)
Discussion started by: gc_sw
3 Replies

3. Shell Programming and Scripting

get 3rd column of nth line

hi; i have a file.txt and its 9th, 10th and 11th line lines are: RbsLocalCell=S2C1 maxPortIP 4 (this is 9th line) RbsLocalCell=S3C1 maxPortIP 4 (this is 10th line) RbsLocalCell=S1C1 ... (11 Replies)
Discussion started by: gc_sw
11 Replies

4. Shell Programming and Scripting

How to start reading from the nth line till the last line of a file.

Hi, For my reuirement, I have to read a file from the 2nd line till the last line<EOF>. Say, I have a file as test.txt, which as a header record in the first line followed by records in rest of the lines. for i in `cat test.txt` { echo $i } While doing the above loop, I have read... (5 Replies)
Discussion started by: machomaddy
5 Replies

5. UNIX for Dummies Questions & Answers

how to delete nth line

can you please tell me (1) how to delete 1st and 3rd line only from a file. (2) How to delete last 4 lines in a file that has 2 blank lines out of last 4 lines. Thank you. (2 Replies)
Discussion started by: Ariean
2 Replies

6. Shell Programming and Scripting

Calculating average for every Nth line in the Nth column

Is there an awk script that can easily perform the following operation? I have a data file that is in the format of 1944-12,5.6 1945-01,9.8 1945-02,6.7 1945-03,9.3 1945-04,5.9 1945-05,0.7 1945-06,0.0 1945-07,0.0 1945-08,0.0 1945-09,0.0 1945-10,0.2 1945-11,10.5 1945-12,22.3... (3 Replies)
Discussion started by: ncwxpanther
3 Replies

7. Shell Programming and Scripting

Print every nth line

Dear all, How to print every nth line. File like this: File input: 1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 (3 Replies)
Discussion started by: attila
3 Replies

8. Shell Programming and Scripting

Print nth line in a file

Bash/Oracle Linux 6.4 A basic requirement. How can I get nth line of a file printed ? Can I use grep in this case ? Example: In the below file, 12th line is "Kernel parameter check passed for rmem_max" . I just want the 12 line to be printed. # cat sometext.txt Kernel version check... (2 Replies)
Discussion started by: John K
2 Replies

9. UNIX for Beginners Questions & Answers

Insert a line of text on nth line of a file

Hi All, I am using UNix Sun OS sun4u sparc SUNW,SPARC-Enterprise My intention is to insert a line of text after 13th line of every file inside a particular directory. While trying to do it for a single file , i am using sed sed '3 i this is the 4th line' filename sed: command garbled: 3... (5 Replies)
Discussion started by: gotamp
5 Replies

10. Shell Programming and Scripting

Printing string from last field of the nth line of file to start (or end) of each line (awk I think)

My file (the output of an experiment) starts off looking like this, _____________________________________________________________ Subjects incorporated to date: 001 Data file started on machine PKSHS260-05CP ********************************************************************** Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
GLFRONTFACE(3G) 														   GLFRONTFACE(3G)

NAME
glFrontFace - define front- and back-facing polygons C SPECIFICATION
void glFrontFace( GLenum mode ) PARAMETERS
mode Specifies the orientation of front-facing polygons. GL_CW and GL_CCW are accepted. The initial value is GL_CCW. DESCRIPTION
In a scene composed entirely of opaque closed surfaces, back-facing polygons are never visible. Eliminating these invisible polygons has the obvious benefit of speeding up the rendering of the image. To enable and disable elimination of back-facing polygons, call glEnable and glDisable with argument GL_CULL_FACE. The projection of a polygon to window coordinates is said to have clockwise winding if an imaginary object following the path from its first vertex, its second vertex, and so on, to its last vertex, and finally back to its first vertex, moves in a clockwise direction about the interior of the polygon. The polygon's winding is said to be counterclockwise if the imaginary object following the same path moves in a counterclockwise direction about the interior of the polygon. glFrontFace specifies whether polygons with clockwise winding in window coordinates, or counterclockwise winding in window coordinates, are taken to be front-facing. Passing GL_CCW to mode selects counterclock- wise polygons as front-facing; GL_CW selects clockwise polygons as front-facing. By default, counterclockwise polygons are taken to be front-facing. ERRORS
GL_INVALID_ENUM is generated if mode is not an accepted value. GL_INVALID_OPERATION is generated if glFrontFace is executed between the execution of glBegin and the corresponding execution of glEnd. ASSOCIATED GETS
glGet with argument GL_FRONT_FACE SEE ALSO
glCullFace(3G), glLightModel(3G) GLFRONTFACE(3G)
All times are GMT -4. The time now is 12:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy