Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Reducing input file size after pattern search Post 302996289 by Xterra on Sunday 23rd of April 2017 05:22:44 PM
Old 04-23-2017
Jim, Rudy and Don
I deeply apologize! Indeed, I did not read well/understand the code and Jim's suggestion when they were first posted. I see the advantages over what I wrote and I am trying to dissect it. Quick question, and for a different application, if my infile has the actual sequence in the second line of the record, something like this:
Code:
@M03333 
AGCTGTGAstring-1GATCAGTGCATGA
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.
@M03333 
AGCTGTGAstring-2GATCAGTGCATGA
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.
@M03333 
AGCTGTGAstring-3GATCAGTGCATGA
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.
@M03333 
AGCTGTGAstring-4GATCAGTGCATGA
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.
@M03333 
AGCTGTGAstring-1GATCAGTGCATGG
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.
@M03333 
AGCTGTGAstring-1GATCAGCCCATGA
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.
@M03333 
AGCTGTGAstring-2CCATCAGTGCATGA
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.
@M03333 
AGCTAAGAstring-2GATCAGTGCATGA
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.

And I would like to output the entire record using Rudi's code, e.g. for outfile file MID-1.txt:
Code:
@M03333 
AGCTGTGAstring-1GATCAGTGCATGA
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.
@M03333 
AGCTGTGAstring-1GATCAGTGCATGG
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.
@M03333 
AGCTGTGAstring-1GATCAGCCCATGA
+
CCCCCCCCCCCCCCGGGGGGGGG;;;;.,..,.

I would need to change the RS to \n, correct? How could I modify Rudi's code so I can append the two other lines?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search file for pattern and grab some lines before pattern

I want to search a file for a string and then if the string is found I need the line that the string is on - but also the previous two lines from the file (that the pattern will not be found in) This is on solaris Can you help? (2 Replies)
Discussion started by: frustrated1
2 Replies

2. Programming

reducing size of executeable in C under Unix

Hi, Could any one tell me how to reduce the size of an executable file of C under Unix. thanks (2 Replies)
Discussion started by: useless79
2 Replies

3. Solaris

reducing to root file size

My root file size has reached 80% and I am looking where all i can reduce the file size . Here is the output of top directories in / . To me none of this looks useful but not sure . We use an appplication and email. Which all can be deleted . Please advise . 2016989 989445 /var 930059 ... (2 Replies)
Discussion started by: Hitesh Shah
2 Replies

4. Shell Programming and Scripting

How to assign the Pattern Search string as Input Variable

guys, I need to know how to assing pattern matched string as an input command variable. Here it goes' My script is something like this. ./routing.sh <Server> <enable|disable> ## This Script takes an input <Server> variable from this line of the script ## echo $1 | egrep... (1 Reply)
Discussion started by: raghunsi
1 Replies

5. Shell Programming and Scripting

Search for a pattern in a String file and count the occurance of each pattern

I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported Input file is a free flowing file without any format example of output ERR-00001=5 .... ERR-01010=10 ..... ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies

6. Shell Programming and Scripting

How to use sed to search a particular pattern in a file backward after a pattern is matched.?

Hi, I have two files file1.txt and file2.txt. Please see the attachments. In file2.txt (which actually is a diff output between two versions of file1.txt.), I extract the pattern corresponding to 1172c1172. Now ,In file1.txt I have to search for this pattern 1172c1172 and if found, I have to... (9 Replies)
Discussion started by: saurabh kumar
9 Replies

7. Shell Programming and Scripting

Reducing the decimal points of numbers (3d coordinates) in a file; how to input data to e.g. Python

I have a file full of coordinates of the form: 37.68899917602539 58.07500076293945 57.79100036621094 The numbers don't always have the same number of decimal points. I need to reduce the decimal points of all the numbers (there are 128 rows of 3 numbers) to 2. I have tried to do this... (2 Replies)
Discussion started by: crunchgargoyle
2 Replies

8. Shell Programming and Scripting

Search pattern in a file taking input from another file

Hi, Below is my requirement File1: svasjsdhvassdvasdhhgvasddhvasdhasdjhvasdjsahvasdjvdasjdvvsadjhv vdjvsdjasvdasdjbasdjbasdjhasbdasjhdbjheasbdasjdsajhbjasbjasbhddjb svfsdhgvfdshgvfsdhfvsdadhfvsajhvasjdhvsajhdvsadjvhasjhdvjhsadjahs File2: sdh hgv I need a command such that... (8 Replies)
Discussion started by: imrandec85
8 Replies

9. Shell Programming and Scripting

Grep command to search pattern corresponding to input from user

One more question: I want to grep "COS_12_TM_4 pattern from a file look likes : "COS_12_TM_4" " ];I am taking scan_out as the input from the user. How to search "COS_12_TM_4" in the file which is corresponds to scan_out (12 Replies)
Discussion started by: Preeti Chandra
12 Replies

10. UNIX for Beginners Questions & Answers

Grep/awk using a begin search pattern and end search pattern

I have this fileA TEST FILE ABC this file contains ABC; TEST FILE DGHT this file contains DGHT; TEST FILE 123 this file contains ABC, this file contains DEF, this file contains XYZ, this file contains KLM ; I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Discussion started by: vbabz
2 Replies
TR(1)							      General Commands Manual							     TR(1)

NAME
tr - translate characters SYNOPSIS
tr [ -cds ] [ string1 [ string2 ] ] DESCRIPTION
Tr copies the standard input to the standard output with substitution or deletion of selected characters. Input characters found in string1 are mapped into the corresponding characters of string2. When string2 is short it is padded to the length of string1 by duplicat- ing its last character. Any combination of the options -cds may be used: -c complements the set of characters in string1 with respect to the universe of characters whose ASCII codes are 01 through 0377 octal; -d deletes all input characters in string1; -s squeezes all strings of repeated output characters that are in string2 to single characters. In either string the notation a-b means a range of characters from a to b in increasing ASCII order. The character `' followed by 1, 2 or 3 octal digits stands for the character whose ASCII code is given by those digits. A `' followed by any other character stands for that character. The following example creates a list of all the words in `file1' one per line in `file2', where a word is taken to be a maximal string of alphabetics. The second string is quoted to protect `' from the Shell. 012 is the ASCII code for newline. tr -cs A-Za-z '12' <file1 >file2 SEE ALSO
ed(1), ascii(7) BUGS
Won't handle ASCII NUL in string1 or string2; always deletes NUL from input. TR(1)
All times are GMT -4. The time now is 06:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy