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
Locale::Codes::LangFam(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangFam(3pm)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Locale::Codes::LangFam(3pm)
All times are GMT -4. The time now is 11:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy