All Questions
Tagged with pattern-matching text-processing
19 questions
5
votes
9
answers
1k
views
How to put text inside text automatically?
I need to put one text inside another text.
1) I have a file with list of input values:
A1
B2
C3
D4
E5
I have a wrapper pattern which should contain the text:
$wgSpecialPageLockdown['INPUT_COMES_HERE'...
1
vote
6
answers
1k
views
print lines between 1st occurence of 1st pattern to last occurence of 2nd pattern with AWK
I have a datafile, with dates in 2nd column
# cat datafile
-;20210106;-;-;-;
-;20210112;-;-;-;
-;20210112;-;-;-;
-;20210112;-;-;-;
...
-;20210217;-;-;-;
-;20210217;-;-;-;
-;20210217;-;-;-;
-;20210217;-...
2
votes
1
answer
46
views
Loop through file with unique identifer and compute cumulative sum
I have a large text file, as shown below, where column1-colum3 define a region and fourth column is unique identifier. The column 6 is assigned value of the region.
chr6 26204834 26204839 ...
1
vote
2
answers
2k
views
How to merge two files based on the matching of one column?
I have two files, B.csv:
1,AD
2,AB
3,AC
5,AF
7,AE
and C.csv:
1,x
3,z
5,y
How do I get this output:
1,AD,x
2,AB,
3,AC,z
5,AF,y
7,AE,
by matching the common column 1 in both of the files?
0
votes
2
answers
503
views
Regex that grep numbers after specific string in multiple files and return average
I would like to return the average of all numbers after a specific string in multiple files i.e.
We are given 10 files (file1.txt,...,file10.txt). Each file contains among others
Test1: Avg. length 24....
-1
votes
1
answer
137
views
Custom data formatting and pattern matching
I am trying to format custom data using pattern match. I am not getting expected format. Though I am not shell script savvy but I was able to build a script based on references from multiple sources ...
1
vote
2
answers
432
views
Grep two files and print lines with multiple hits
I have two files.
file1.txt
abc
def
ghi
jkl
mno
pqr
file2.txt
abc ghi
abc xyz
xyz xyz
mno jkl
def stu
(column separator is tab)
I am trying to grep the file1.txt against file2.txt sort of like this:
...
9
votes
12
answers
2k
views
How do I print the last sequence of lines between a start and an end pattern?
Answers to this question:
How to grep lines between start and end pattern?
are not concerned with multiple sequences of lines which fall between the match patterns. Thus, for example, sed -n '/...
3
votes
3
answers
22k
views
How to get group results using grep?
How would I get this output:
Found value: This order was placed for QT3000! OK?
or
Found value: This order was placed for QT300
or
Found value: 0
using line.txt and pattern.txt as below:
[nsaunders@...
0
votes
2
answers
104
views
I need to fetch the relay=hostname.com from the sendmail logs
I need to fetch the
relay=sender.hostname.com
from the Sendmail log example below.
sendmail[0000]: 03O7cddddddd: from=<[email protected]>, size=782, class=0, nrcpts=1, msgid=<...
0
votes
2
answers
57
views
Extract match and everything before next match, do it for every match
I have a file with this structure:
>Cluster 0
0 51aa, >MG00HS05:520:C8M1TACXX:3:1101:1428:2080/1... *
1 51aa, >MG00HS05:520:C8M1TACXX:3:1101:1658:2480/1... at 3:51:1:49/96.08%
2 ...
0
votes
2
answers
120
views
Extracting lines to new files
Say I have a large CSV file with a header and several columns. For the purpose of this question I will consider a small file with just two columns. We can call it use_rep.
user_id,rep
885,500K+
22565,...
1
vote
1
answer
357
views
Compare two text files, extract matching rows of file2 plus additional rows
have been mocking around with this too long and tried grep, join, awk but I cant get the parameters right. I need to get the command right.
I have got two text files.
cat file1
@ABC:11:ABC:1:1111:...
3
votes
4
answers
3k
views
Parse all strings of specific length?
I've exported my email archive of 10 years which is very large.
I want to parse all the text for any string that is 64 characters long in search of a bitcoin private key.
How can I parse strings of ...
1
vote
4
answers
1k
views
How to extract word which has only numbers separated by 'dot'
From below lines
abcd efgh ijhk lmn opqrs 9.0.8.2c tuv wxyz
abcd efgh ijhk lmn opqrs 8.1.3.9b
How to extract only
9.0.8.2c
8.1.3.9b