Hi,
I am counting no. of lines in a file using cat like this on a unix system.
$line_count = `cat $filename | wc -l`
This works fine. But one of the files having a blank in int's path like this.
Module: /org/trans/program files/src/apptask1.c.
Then the above my code to count lines fails. Also some times when the path is big it breaks in to two lines and I unable to pickup the file name properly. I am reading file names from a file. So how to find the file name if in two lines in a file? For ex:
Module: /org/trans/program files/dir1/dir2/dir3/dir4/
dir5/apptask2.c
I able to read first line /org/trans/program files/dir1/dir2/dir3/dir4/ only. I do not know when the file name breaks into two lines. Each file name is preceded by "Module: ". So my regular expression is to match a line beginning with 'Module: ' and pickup the remaining text as a file name. So can any one help me?
Thanks
Ashok
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|