10-04-2009
Print rows, having pattern in specific column...
Hello all,
I have a pattern file some what like this,
cd003
cd005
cd007
cd008
and input file like this,
abc cd001 cd002 zca
bca cd002 cd003 cza
cba cd003 cd004 zca
bac cd004 cd005 zac
cba cd005 cd006 acz
acb cd006 cd007 caz
cab cd007 cd008 azc
I want to print all the rows which have the pattern in column 3 ?
Is it possible to give patterns from a file, in AWk ?
How to do it in shell scripting (without using AWk) ?
THANKS IN ADVANCE
Last edited by admax; 10-04-2009 at 04:38 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
This is my input file:
ali 5 usa abc
abu 4 uk bca
alan 6 brazil bac
pinky 10 utah sdc
My desired output:
pinky 10 utah sdc
alan 6 brazil bac
ali 5 usa abc
abu 4 uk bca
Based on the column two, I want to do the descending order and print out other related column at the... (3 Replies)
Discussion started by: patrick87
3 Replies
2. Shell Programming and Scripting
Input file:
adc_0123
haa_1000
bcc_520
adc_0150
bcc_290
adc_0112
haa_8000
adc_0139
haa_7000
Output file:
adc_0123 adc_0123
haa_1000
bcc_520
adc_0150 adc_0150
bcc_290 (3 Replies)
Discussion started by: patrick87
3 Replies
3. Shell Programming and Scripting
abc.dat
tty cpu
tin tout us sy wt id
0 0 7 3 19 71
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0
0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx
I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies
4. Shell Programming and Scripting
Can anyone please help with this? I have 2 files as given below.
If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value.
file1
abc_1 foo1@a ....
abc_1 soo2@a ...
def_2 soo2@a ....
def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies
5. UNIX for Dummies Questions & Answers
I'm still beginner and maybe someone can help me.
I have this input:
the great warrior a, b, c
and what i want to know is, with awk, how can i detect the string with 'warrior' string on it and print the a, b, and c seperately, become like this :
Warrior Type
a
b
c
Im still very... (3 Replies)
Discussion started by: radynaraya
3 Replies
6. Shell Programming and Scripting
Dear All,
I have a data file input.csv like below. (Only five column shown here for example.)
Data1,StepNo,Data2,Data3,Data4
2,1,3,4,5
3,1,5,6,7
3,2,4,5,6
5,3,5,5,6
From this I want the below output
Data1,StepNo,Data2,Data3,Data4
2,1,3,4,5
3,1,5,6,7
where the second column... (4 Replies)
Discussion started by: ks_reddy
4 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I have a tab delimited text file where I want to delete all rows that have the same string for column 1. How do I go about doing that? Thanks!
Example Input:
aa 1
aa 2
aa 3
bb 4
bc 5
bb 6
cd 8
Output:
bc 5
cd 8 (4 Replies)
Discussion started by: evelibertine
4 Replies
8. Shell Programming and Scripting
Dear fellows, I need your help.
I'm trying to write a script to convert a single column into multiple rows.
But it need to recognize the beginning of the string and set it to its specific Column number.
Each Line (loop) begins with digit (RANGE).
At this moment it's kind of working, but it... (6 Replies)
Discussion started by: AK47
6 Replies
9. Shell Programming and Scripting
Hello....
Pls help me (and sorry my english) :)
So
I have a file (test.txt) with 1 long line.... for example:
isgc jsfh udgf osff 8462 error iwzr 653 idchisfb isfbisfb sihfjfeb isfhsi gcz eifh
How to print after the "error" word the 2nd 4th 5th and 7th word??
output well be:
653 isfbisfb... (2 Replies)
Discussion started by: marvinandco
2 Replies
10. UNIX for Beginners Questions & Answers
Hi all,
I have searched and searched, but I have not found a solution that quite fits what I am trying to do.
I have a long list of data in three columns. Below is a sample:
1,10,8
2,12,10
3,13,12
4,14,14
5,15,16
6,16,18
Please use code tags
What I need to do is as follows: If a... (4 Replies)
Discussion started by: bleedingturnip
4 Replies
LEARN ABOUT DEBIAN
z88dk-copt
copt(1) z88 Development Kit copt(1)
NAME
copt - peephole optimizer
SYSNOPIS
copt file ...
DESCRIPTION
copt is a general-purpose peephole optimizer. It reads code from its standard input and writes an improved version to its standard output.
copy reads the named files for its optimizations, which are encoded as follows:
<pattern for input line 1>
<pattern for input line 2>
...
<pattern for input line n>
=
<pattern for output line 1>
<pattern for output line 2>
...
<pattern for output line m>
<blank line>
Pattern matching uses literal string comparison, with one exception: ``%%'' matches the ``%'' character, and ``%'' followed by a digit
matches everything up to the next occurrence of the next pattern character, though all occurrences of %n must denote the same string. For
example, the pattern ``%1=%1.'' matches exactly those strings that begin with a string X, followed by a ``='' (the first), followed by a
second occurrence of X, followed by a period. In this way, the input/output pattern
mov $%1,r%2
mov *r%2,r%2
=
mov %1,r%2
commands copt to replace runs like
mov $_a,r3
mov *r3,r3
with
mov _a,r3
Note that a tab or newline can terminate a %n variable.
copt compares each run of input patterns with the current input instruction and its predecessors. If no match is found, it advances to the
next input instruction and tries again. Otherwise, it replaces the input instructions with the corresponding output patterns, pattern vari-
ables instantiated,and resumes its search with the first instruction of the replacement. copt matches input patterns in reverse order to
cascade optimizations without backing up.
BUGS
Errors in optimization files are always possible.
SEE ALSO
z88dk(1), z88dk-zcc(1), z88dk-z80asm(1), z88dk-appmake(1), z88dk-copt(1).
AUTHOR
z88dk was written by Dominic Morris <dom@z88dk.org>, and others.
01 December 2009 copt(1)