I am searching for "o" then prints all lines with "o". Any suggestion/code I must apply?
data.txt:
j,o,b:
a,b,d:
o,l,e:
f,a,r:
e,x,o:
desired output:
j,o,b:
o,l,e:
e,x,o:
I am searching for "o" then prints all lines with "o". Any suggestion/code I must apply?
data.txt:
j,o,b:
a,b,d:
o,l,e:
f,a,r:
e,x,o:
desired output:
j,o,b:
o,l,e:
e,x,o:
grep "o" data.txt
Does that help? I don't know Perl, but you can get the same output using the above grep.
If you have grep on your system, then grep o data.txt
from the command line should do the trick.
Failing that, you could try Perl:
open IN, 'data.txt';
my @l = <IN>;
close IN;
foreach my $l (@l) {
$l =~ /o/ and print $l;
}
In Perl:
while (<>) { print if /o/; }
or with grep:
grep 'o' data.txt