Get First String in a file-Perl


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Get First String in a file-Perl
Prev   Next
# 2  
Old 12-03-2009
Code:
$perl -e 'while(<>){  exit if(/DISPLAY/); print $_; }' < test

This perl one liner will print the lines from the file called test.. If it gets the string DISPLAY, it just exit from the execution. Hope this helps you.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script to read string from file#1 and find/replace in file#2

Hello Forum. I have a file called abc.sed with the following commands; s/1/one/g s/2/two/g ... I also have a second file called abc.dat and would like to substitute all occurrences of "1 with one", "2 with two", etc and create a new file called abc_new.dat sed -f abc.sed abc.dat >... (10 Replies)
Discussion started by: pchang
10 Replies

2. Shell Programming and Scripting

Need to search a particular String form a file a write to another file using perl script

I have file which contains a huge amount of data. I need to search the pattern Message id. When that pattern is matched I need to get abcdeff0-1g6g-91g3-1z2z-2mm605m90000 to another file. Kindly provide your input. File is like below Jan 11 04:05:10 linux100 |NOTICE... (2 Replies)
Discussion started by: Raysf
2 Replies

3. Shell Programming and Scripting

How to replaces a value in a file after a particular string using perl?

I need to replace the value of notifications_enabled to 0 if the value already set to 1 and vice versa(not the other values and spaces remain same after the value changed). I tried the below program for that. Can any one help me out. file:test.cfg define host { hostgroups ... (2 Replies)
Discussion started by: praveen265
2 Replies

4. Shell Programming and Scripting

perl- read search and replace string from the file

Dear all, I have a number of files and each file has two sections separated by a blank line. At the top section, I have lines which describes the values of the alphabetical characters, # s #; 0.123 # p #; 12.3 # d #; -2.33 # f #; 5.68 <blank line> sssssss spfdffff sdfffffff Now I... (4 Replies)
Discussion started by: sasharma
4 Replies

5. Shell Programming and Scripting

Searching a string in a file using perl

Hi I would like to read a file using perl and search for a string (last entry). Then read that into an array and do further grep File content for ex: comp=a,value=30,runtime=12,type=lic comp=d,value=15,runtime=2,type=lic comp=a,value=90,runtime=43,type=lic... (1 Reply)
Discussion started by: vivek_damodaran
1 Replies

6. Shell Programming and Scripting

Perl Look for string in file

Hi Guys In perl how can i look for a string in side a file and return something if it exists a little bit of background i have made a wrapepr for a program but in order for the program to work i need to modify a file first, i want to stick something in the wrapper that will tell if the sting... (1 Reply)
Discussion started by: ab52
1 Replies

7. Shell Programming and Scripting

extract string and sending it into a new file in perl program

Hi, I have a input file with following values (test.out) I would like to grep all lines with word 'PANIC' and sent it another file using perl program with grep command. I have been trying different ways and not working. Pls advice. Thanks a lot for the help. --example--... (3 Replies)
Discussion started by: hudson03051nh
3 Replies

8. Shell Programming and Scripting

Extract string from a file & write to a new file (Perl)

Hi, This is the first time playing around with perl and need some help. Assuming if i have a line of text that looks like this: Date/Time=Nov 18 17:12:11;Device Name=192.168.1.1;Device IP=192.168.1.1;Device Class=IDS;Source IP=155.212.212.111;Source Name=UNKNOWN;Source Port=1679... (3 Replies)
Discussion started by: LuckyGuy
3 Replies

9. Shell Programming and Scripting

PERL: Searching for a string in a text file problem

Looking for a bit of help. I need to search for a string of words, but unfortunately these words are located on separate lines. for example the text output is: United Chanmpions Ronaldo Liverpool Losers Torres and my script code is print("DEBUG - checking file message"); while... (15 Replies)
Discussion started by: meevagh
15 Replies

10. Shell Programming and Scripting

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:... (4 Replies)
Discussion started by: pondlife
4 Replies
Login or Register to Ask a Question
fvwm-perllib(1) 						  Fvwm Utilities						   fvwm-perllib(1)

NAME
fvwm-perllib - shows the documentation of the Fvwm Perl library SYNOPSIS
fvwm-perllib [ --help|-h|-? ] [ --version|-v|-V ] [ man [ Perl::Class ] ] [ cat [ Perl::Class ] ] [ raw [ Perl::Class ] ] [ dir ] DESCRIPTION
Starting from fvwm-2.5.x versions there is a built-in support for creating fvwm modules in Perl. This fvwm-perllib utility provides help services for the Fvwm Perl library. OPTIONS
--help show the help and exit --version show the version and exit --man or man [ Perl::Class ] show manual page just like man(1) --cat or cat [ Perl::Class ] show manual page in plain text --raw or raw [ Perl::Class ] generate output in man format (not human readable) --dir or dir print perllib directory without a trailing end of line USAGE
Use this in the fvwm modules written in Perl: use lib `fvwm-perllib dir`; Introduction to the Fvwm Perl library: % fvwm-perllib man Manual page for the "FVWM::Module" class: % fvwm-perllib man FVWM::Module Standard options: % fvwm-perllib --help % fvwm-perllib --version AUTHORS
Mikhael Goikhman <migo@homemail.com>. COPYING
The script is distributed by the same terms as fvwm itself. See GNU General Public License for details. BUGS
No known bugs. Report bugs to fvwm-bug@fvwm.org. 2.5.28 (from cvs) 2009-03-22 fvwm-perllib(1)