I am new to Perl. I want to find a string in some file, and then I want the whole string to contain the string.
perl -ne 'print if m/whatever/' file
Open file
Loop while there are lines to read from the file
2.1 Using regular expressions , check if the string matches the pattern: if ($line =~ /pattern/) .
if ($line =~ /pattern/)
2.2 If yes, print string
Close file.
if ( !open(LOGFILE, "<myfile.log") ) { print "ERROR: failed to open myfile.log\n";} else { while (<LOGFILE>){ if ($_ =~ /pattern/) { print "found\n"; break; } } close (LOGFILE); }
Source: https://habr.com/ru/post/1380005/More articles:CSS print mode - Div at the bottom of the last page - htmlWhy can't I change the backcolor property at design time or runtime? - propertiesReflection in C # not working with COM (and C ++) - c ++Using Reflection with COM Interop - reflectionKerberos Cached Ticket - java"Unresolved compilation issues" from running MPJ express in Eclipse Indigo - javaAndroid: BatteryLevel widget not updating - androidjava.io.FileNotFoundException: null \ conf \ wrapper.conf (the system cannot find the path specified) - javaApplication settings without saving in app.config - .netChange element type with jQuery - javascriptAll Articles