![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PERL: Searching for a string in a text file problem | meevagh | Shell Programming and Scripting | 15 | 05-01-2008 10:57 AM |
| searching for a string in a file | ROOZ | UNIX for Dummies Questions & Answers | 2 | 03-07-2008 01:54 PM |
| Extracting a string from one file and searching the same string in other files | mohancrr | Shell Programming and Scripting | 1 | 09-19-2007 03:17 AM |
| Complicated string searching in a file | nir_s | Shell Programming and Scripting | 5 | 09-21-2005 07:51 AM |
| searching for a string though file system | peter.herlihy | UNIX for Dummies Questions & Answers | 3 | 12-06-2001 04:19 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Perl: searching for a string in a file...
Hi All,
I need to search for a string in a file that I've opened and base a decision on the result. The logic is this: "if the word 'Shared' appears on the first line then do this on the whole file else do this on the whole file " The code I currently have isn't working: Code:
if ($. = 1 && $_ =~ /^*Shared*$/) {
$_ if ($awk - $F) . "\",\"";if ($. != 1) {
$n = substr($Fld[11], 1, length($Fld[11]) - 2);
$lines{$. - 1} = $n;
}
} else {
$_ if ($awk - $F) . "\",\"";if ($. != 1) {
$n = $Fld[10];
$lines{$. - 1} = $n;
}
}
Thanks in advance. |
| Bookmarks |
| Tags |
| perl, perl shift, regex, regular expressions, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|