Sponsored Content
Full Discussion: Grep and Print
Top Forums UNIX for Dummies Questions & Answers Grep and Print Post 302771646 by Abhayman on Thursday 21st of February 2013 06:50:22 AM
Old 02-21-2013
Hi ,

The command works fine
perl -lne '(/File NameSmilie\d+).*?time taken.*?Smilie\d+)/ || /File Name:.*?\](\d+).*?time takenSmilie\d+)/) && print "$1 -- $2"'

But if the name is alphanumberic (DLFE-192818716.pptx) it doesnt work . I tried with /w option but that terminates the filename .
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

to grep and print their counts

suppose u have a file ACFCFACCACARCSHFARCVJVASTVAJFTVAJVGHBAJ another file A C F R then output shud be A= 9 C=7 F=3 R=2 Thanks (12 Replies)
Discussion started by: cdfd123
12 Replies

2. Shell Programming and Scripting

using grep and print filename

Hi, I have a question on bash. Basically I would like to print a file name using bash. I am actually trying to grep a particular character in sequential files. I have alot files such that a.txt, b.txt,c.txt...etc. If I found a certain character, I would print that particular filename. I... (5 Replies)
Discussion started by: ahjiefreak
5 Replies

3. Shell Programming and Scripting

Print lines after grep

Hi all, I need help in following scenario. I have a file with about 10,000 lines. There are several lines which have word "START" (all upper case) in them. I want to grep line with word "START" and then do the following 1. Print the line number having word "START" 2. Print the next 11 lines. ... (4 Replies)
Discussion started by: jakSun8
4 Replies

4. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

5. UNIX for Dummies Questions & Answers

Grep & print

I just need to print value 12 digit number after the key *MI*. My big concern is the below lines are not fixed format or length so cant cut based on the position. XSA*00**00**XZ*DA-Paper*30*942411167****MI*010001990802~AEE XSA*00**00**ZZ*EA-aper*30*94169****MI*010001960802~SDRE*ER... (7 Replies)
Discussion started by: gunaah
7 Replies

6. Shell Programming and Scripting

Print lines before and after..not grep -A

Hi I have this in my file 2011-04-18 15:32:11 system-alert-00012: UDP flood! From xxxxxx to yyyyyyyyyy, int ethernet0/2). Occurred 1 times. 2011-04-18 15:32:11 system-alert-00012: UDP flood! From xxxxxx to yyyyyyyyyy, int ethernet0/2). Occurred 1 times. 2011-04-18 15:32:11... (9 Replies)
Discussion started by: zorrox
9 Replies

7. Shell Programming and Scripting

Grep syntax print after certain character

My current code is: user@ubuntu:~/Desktop$ grep -e "\(packaged by\)\|\(employee\)\|\(file name\)\|\(Total Data (MB) Read\)\|\(Begin Time\)" log.txt packaged by = Ron Mexico employee = Michael Vick file name = Mike_Vick_2011.bat Total Data (MB) Read: 11.82 Begin Time: 6/13/2011... (8 Replies)
Discussion started by: chipperuga
8 Replies

8. Shell Programming and Scripting

Grep for the string and then print the next 4 lines

RHEL 5.8 I have a text file like below. I want to grep for a string and then print the next 4 lines including the line with the string I grepped for For eg: I want grep for the string HANS and then print the next 4 lines including HANS $ cat someText.txt JOHN NATIONALITY:... (7 Replies)
Discussion started by: omega3
7 Replies
File::Find::Object(3pm) 				User Contributed Perl Documentation				   File::Find::Object(3pm)

NAME
File::Find::Object - An object oriented File::Find replacement SYNOPSIS
use File::Find::Object; my $tree = File::Find::Object->new({}, @targets); while (my $r = $tree->next()) { print $r ." "; } DESCRIPTION
File::Find::Object does same job as File::Find but works like an object and with an iterator. As File::Find is not object oriented, one cannot perform multiple searches in the same application. The second problem of File::Find is its file processing: after starting its main loop, one cannot easilly wait for another event and so get the next result. With File::Find::Object you can get the next file by calling the next() function, but setting a callback is still possible. FUNCTIONS
new my $ffo = File::Find::Object->new( { options }, @targets); Create a new File::Find::Object object. @targets is the list of directories or files which the object should explore. options depth Boolean - returns the directory content before the directory itself. nocrossfs Boolean - doesn't continue on filesystems different than the parent. followlink Boolean - follow symlinks when they point to a directory. You can safely set this option to true as File::Find::Object does not follow the link if it detects a loop. filter Function reference - should point to a function returning TRUE or FALSE. This function is called with the filename to filter, if the function return FALSE, the file is skipped. callback Function reference - should point to a function, which would be called each time a new file is returned. The function is called with the current filename as an argument. next Returns the next file found by the File::Find::Object. It returns undef once the scan is completed. item Returns the current filename found by the File::Find::Object object, i.e: the last value returned by next(). next_obj Like next() only returns the result as a convenient File::Find::Object::Result object. "$ff->next()" is equivalent to "$ff->next_obj()->path()". item_obj Like item() only returns the result as a convenient File::Find::Object::Result object. "$ff->item()" is equivalent to "$ff->item_obj()->path()". $ff->set_traverse_to([@children]) Sets the children to traverse to from the current node. Useful for pruning items to traverse. $ff->prune() Prunes the current directory. Equivalent to $ff->set_traverse_to([]). [@children] = $ff->get_traverse_to() Retrieves the children that will be traversed to. [@files] = $ff->get_current_node_files_list() Gets all the files that appear in the current directory. This value is constant for every node, and is useful to use as the basis of the argument for "set_traverse_to()". BUGS
No bugs are known, but it doesn't mean there aren't any. SEE ALSO
There's an article about this module in the Perl Advent Calendar of 2006: <http://perladvent.pm.org/2006/2/>. File::Find is the core module for traversing files in perl, which has several limitations. File::Next, File::Find::Iterator, File::Walker and the unmaintained File::FTS are alternatives to this module. LICENSE
Copyright (C) 2005, 2006 by Olivier Thauvin This package is free software; you can redistribute it and/or modify it under the following terms: 1. The GNU General Public License Version 2.0 - http://www.opensource.org/licenses/gpl-license.php 2. The Artistic License Version 2.0 - http://www.perlfoundation.org/legal/licenses/artistic-2_0.html 3. At your option - any later version of either or both of these licenses. perl v5.10.0 2009-06-18 File::Find::Object(3pm)
All times are GMT -4. The time now is 04:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy