I have four columns input data.x,y,z b,c,d are some numbers not necessarily the same.
x 0 z1 bl
x 0 z2 cl
x 0 z3 dl
0 0 z1 bc
0 0 z2 cc
0 0 z3 dc
0 y z1 br
0 y z2 br
0 y z3 br
The data could be separated in blocks of triplets for which the third column is the same.
The sequence z1,z2,z3 would...
simple example inputfile
regex1 regex2 regex3
1 2 3
4 5 6
regex1 regex3 regex2
aa bb cc
7 8 9
If I want to print the next line after the regex2.
In my inptut file
awk '/regex1/{getline;print $0}' inputfile
How can I print only the...
Sample input
1 y 10
2 y 11
3 y 10
4 n 12
5 n 22
6 y 12
7 y 12
8 n 33
9 y 12
10 y 10
11 y 10
12 y 10
13 y 10
14 y 11
If I want to extract list of lines for which $2==y I can do.
awk '$2=="y"{print $1}' list
1
2
3
6
7
9
10
11
12
13
14
What I really need is to print...
#!/bin/bash
while : #infinite loop
do
echo " what is your choice .."
read ch #expects to read only one input
echo " ok your choice is " $ch #execute the simple function with the ch arg
done
Is there a way to do the code above for a random number of input arguments...
I advanced a lot in awk mainly thanks to this forum.
I am posting here my latest creation and the way I arrived to it. I am asking you gurus for alternative way to do this or for possible improvements, suggestions ....
Here is the example infile
$cat infile
#S 1 line one contents...
Test file
$cat testfile
a b c
1 2 3
begin line with first regex
block 1 11
between 2 12
regex 3 13
end line with last regex
4 5 6
blah blah
I need another method printing the block between two regular expressions
where the entire code is in “{ }” brackets.
I was...
Example data.in hundreds of blocks that look something like that
#S 1
a b c d
11 2 3 0
31 5 6 1
72 8 9 2
end block one
#S 2
a f g h
24 3 4 0
62 7 8 1
52 6 8 2
45 7 9 3
87 4 1 4
end block two
#S 3
d g k j
11 4 5 0
33 1 3 1
43 4 6 2
end block three
The numbers of lines with numbers is...
Awk gsub between the first two regular expressions in multiple dirs.
Hello.
I create 10 directories at once with
$for (( i=0; i<10; i++)) ;do mkdir $i; done
In all of these 10 directories I copy the same file parsec.in.
I know how to print between the two regexp
$awk ' /begin...
I know how to do OR in awk
awk '/regexp1|regexp2|regexp3/{print}' filename
or sed
sed -n '/regexp1\|regexp2/\|regexp3/p' filename
and grep
grep "regex1\|regexp2" filename
mathes lines regex1 or regex2 or regexp3
How do I match lines containing only regexp1 AND regexp2 AND regexp3...
I have the data file which looks like that
#S 1 …............
#D Tue ….......
…....................
…....................
#S 350 a2scan oh -4.42031 -3.62031 or 0.298354 0.381046 28 -600000
#D Tue Feb 17 05:02:03 2009
#P7 S4L S4R S5L...
Hello.
I am in a process of learning awk.
I read and tested most of the examples in the gnu awk users guide regarding the arrays.
I also went through this forum in search for solution to my current problem.
I have one file with about thousand lines which looks like that.
data1
S 1 A 20...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.