Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Extract Numbers from a log file Post 302846899 by Sajjadmehdi on Monday 26th of August 2013 03:13:29 AM
Old 08-26-2013
Extract Numbers from a log file

Hi,

I am trying to grep/extract the number list from this log file, can I get some help on this. I can grep the word 'href' to see the numbers, but it is resulting with the complete line.

Content of my file:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of Directory/Temp</title>
</head>
<body>
<h1>Index of Directory/Temp</h1>
<pre>Name  Last modified      Size</pre>
<hr/>
<pre><a href="https://www.unix.com/">../</a>
<a href="129/"">129/</a>   22-Aug-2013 10:00    -
<a href="133/"">133/</a>   21-Aug-2013 14:04    -
<a href="134/"">134/</a>   21-Aug-2013 14:10    -
<a href="135/"">135/</a>   21-Aug-2013 14:12    -
<a href="136/"">136/</a>   21-Aug-2013 14:15    -
</pre>
<hr/>
<address style="font-size:small;"> Server at Test Port 80</address>
</body>
</html>

Expecting output is :
Code:
129
133
134
135
136


Last edited by Franklin52; 08-26-2013 at 04:36 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extract only the "numbers" that are present in this file to a seperate file..

It may sounds too easy but appreciate any help on this.. i have a file with the below details: ****************************************** Please find the locked pernr details for the Time evaluation Personnel number could not be locked Person rejected: 04552737 Personnel number could not... (4 Replies)
Discussion started by: rohit.shetty84
4 Replies

2. Shell Programming and Scripting

Extract numbers below words with awk

Hi all, Please some help over here. I have a Sales.txt file containing info in blocks for every sold product in the pattern showed below (only for 2 products). NEW BLOCK SALE DATA PRODUCT SERIAL 79833269999 146701011945004 .Some other data .Some... (17 Replies)
Discussion started by: cgkmal
17 Replies

3. Shell Programming and Scripting

extract numbers from a word

Hi ppl, I am a bit lost on this...can some one assist. I know this can be down with awk or sed, but i cant get the exact syntax right. I need to only extract the numbers from a signle word ( eg abcd.123.xyz ) How can i extract 123 only ? Thanks (14 Replies)
Discussion started by: systemali
14 Replies

4. Shell Programming and Scripting

Extract numbers from text file work out average

Just wondering if someone could assist me with shell script I'm trying to write. I need to read the final column of a text file (shown below) and workout what the average number is. The text file will have a variable number of lines, I just want the script to pull out the values in the final field... (14 Replies)
Discussion started by: rich@ardz
14 Replies

5. UNIX for Dummies Questions & Answers

Extract numbers from .txt file

I need to extract all the p-value numbers and the rho numbers from a .txt file and write them as coma separated values in a new file. Ideally I would get two files in the end, one for p- values and one for rho. Any suggestions? I appreciate your help!!! The .txt file looks essentially like this... (5 Replies)
Discussion started by: eggali
5 Replies

6. Shell Programming and Scripting

Need help please with Grep/Sed command to extract text and numbers from a file

Hello All, I need to extract lines from a file that contains ALPHANUMERIC and the length of Alphanumeric is set to 16. I have pasted the sample of the lines from the text file that I have created. My problem is that sometimes 16 appears in other part of the line. I'm only interested to... (14 Replies)
Discussion started by: mnassiri
14 Replies

7. Shell Programming and Scripting

Extract rows from file based on row numbers stored in another file

Hi All, I have a file which is like this: rows.dat 1 2 3 4 5 6 3 4 5 6 7 8 7 8 9 0 4 3 2 3 4 5 6 7 1 2 3 4 5 6 I have another file with numbers like these (numbers.txt): 1 3 4 5 I want to read numbers.txt file line by line. The extract the row from rows.dat based on the... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

8. Shell Programming and Scripting

Extract numbers from file name-how to ?

Hello friends,I am new to Unix programming. how do I achieve the following in Unix shell script (I am running ksh on AIX) extract the number from name of file? My file format is like "LongFileName-1234.020614-221030.txt" now I want to extract value which is between (-) hyphen and (.) dot... (4 Replies)
Discussion started by: f150
4 Replies

9. Shell Programming and Scripting

Extract numbers from output file and compare to value

Hi, I developed a script which finally originates a similar output: net0:up,Tx=475198bps,Rx=31009bps net1:up,Tx=39596bps,Rx=35678bps Of course the figures change and also the amount of interfaces (ex: could be more then net0 and net1). This is done automatically. The next step i'm... (4 Replies)
Discussion started by: nms
4 Replies

10. UNIX for Beginners Questions & Answers

Substr with % - extract numbers only

# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.5 (Maipo) I have this script that will monitor filesystems and send me e-amil alerts. #! /bin/ksh DIST_LIST=monitor@...com WORKDIR=/home/monitor WARNLEVEL=90 MAIL_SUBJ="filesystems monitor on "$(hostname) ... (3 Replies)
Discussion started by: danielshell
3 Replies
Test::TempDir(3pm)					User Contributed Perl Documentation					Test::TempDir(3pm)

NAME
Test::TempDir - Temporary files support for testing. SYNOPSIS
use Test::TempDir; my $test_tempdir = temp_root(); my ( $fh, $file ) = tempfile(); my $directory_scratch_obj = scratch(); DESCRIPTION
Test::TempDir provides temporary directory creation with testing in mind. The differences between using this and using File::Temp are: o If "t/tmp" is available (writable, creatable, etc) it's preferred over $ENV{TMPDIR} etc. Otherwise a temporary directory will be used. This is "temp_root" o Lockfiles are used on "t/tmp", to prevent race conditions when running under a parallel test harness. o The "temp_root" is cleaned at the end of a test run, but not if tests failed. o "temp_root" is emptied at the begining of a test run unconditionally. o The default policy is not to clean the individual "tempfiles" and "tempdirs" within "temp_root", in order to aid in debugging of failed tests. EXPORTS
temp_root The root of the temporary stuff. tempfile tempdir Wrappers for the File::Temp functions of the same name. The default options are changed to use "temp_root" for "DIR" and disable "CLEANUP", but these are overridable. scrach Loads Directory::Scratch and instantiates a new one, with the same default options as "tempfile" and "tempdir". SEE ALSO
File::Temp, Directory::Scratch, Path::Class VERSION CONTROL
This module is maintained using Git. You can get the latest version from <git://github.com/nothingmuch/test-tempdir.git>. AUTHOR
Yuval Kogman <nothingmuch@woobling.org> COPYRIGHT
Copyright (c) 2008 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2009-08-11 Test::TempDir(3pm)
All times are GMT -4. The time now is 03:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy