03-18-2010
awk extract a string from a file
Hi,
I have a file which has thousand of lines with lines starting with
Quote:
[2010-03-03 16:28:44.035] DEBUG 2010-03-03 16:28:44,035 DEBUG :[ACTIVE]
And I want to extract and show to user only the below string from all the lines
Quote:
[2010-03-03 16:28:44.035]
Please note note that the above string is a time stamp and it would be different on all the lines.
Please tell me how to extract and show only these string from a file.
Thanks in advance
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm executing "wc -lc" command in a c shell script to get record count and byte counts and writing them to a file. I get the result with the full pathname of the file. But I do not want the path name to be printed in the output file. I heard that using Awk we can get this but I don't have any... (4 Replies)
Discussion started by: stakuri
4 Replies
2. Shell Programming and Scripting
Hi All,
I am new to this shell scripting world. Struck up with a problem, can anyone of you please pull me out of this.
Requirement : Need to get the index of a substring from a parent string
Eg : index("Sandy","dy") should return 4 or 3.
My Approach :
I used Awk function index to... (2 Replies)
Discussion started by: sandeepms17
2 Replies
3. Shell Programming and Scripting
Input File:
=====================================
"Server1" srvgrp="group1" srvid=10
CLOPT="-A -r -e /path/logfile -o /path/stdout"
VAR1=0666 VAR2=N VAR3=0666 MIN=3 VAR4=4 VAR5=N
VAR6=FASTPATH
VAR7=5 VAR8=86400 VAR9=Y
... (20 Replies)
Discussion started by: kaustubh137
20 Replies
4. Shell Programming and Scripting
Hi, guys. I have one question:
I need to search for a string in a file, and then extract another string from the file and assign it to a variable.
For example:
the contents of the file (group) is below:
...
ftp:x:23:
mail:x:34
...
testing:x:2001
sales:x:2002
development:x:2003
...... (6 Replies)
Discussion started by: daikeyang
6 Replies
5. Shell Programming and Scripting
Below are the content of my file and i need to extract the 6 digit numbers after the word barcode, how can i do this?
for example i need to extract 004119,004275,004030 to a new file.
Logically move media ID 004119 (barcode 004119) from standalone to slot 18.
Logically move media ID 004275... (9 Replies)
Discussion started by: shehzad_m
9 Replies
6. Shell Programming and Scripting
hello forum members
I have txt file which consists the following information.
Server: abababa.xyz.ap.mxmx.com
Address: 111.143.211.202
Name: rmxd.ipc.ap.mxmx.com
Address: 144.111.99.9
from the abovefile i have to extract only string "rmxd.ipc.ap.mxmx.com" through awk command.... (1 Reply)
Discussion started by: rajkumar_g
1 Replies
7. Shell Programming and Scripting
I'd like to copy strings from a log file and put them into a CSV.
The strings could be on different line numbers, depending on size of log.
Example Log File:
File = foo.bat
Date = 11/11/11
User = Foo Bar
Size = 1024
...
CSV should look like:
"foo.bat","11/11/11","Foo Bar","1024" (7 Replies)
Discussion started by: chipperuga
7 Replies
8. Shell Programming and Scripting
I want to extract the proper names with awk from a very long string, like: õ(k): </span><br /><a something="pls/pe/person.person?i_pers_id=3694&i_topic_id=2&i_city_id=3372&i_county_id=-1" target="_blank"><b>Gary Oldman</b></a> (George Smiley)<br /><a... (12 Replies)
Discussion started by: lyp
12 Replies
9. Shell Programming and Scripting
Hi,
May i ask if someone share some command for extracting a string between 2 ref string in a txt file
My objective: i had a file with multiple lines and wants only to extract the string "watch?v=IbkAXOmEHpY" or "watch?v=<11 random character>", when i used "grep 'watch?=*' i got a results per... (4 Replies)
Discussion started by: jao_madn
4 Replies
10. UNIX for Beginners Questions & Answers
Hi -
i have one file with content as below.
***** BEGIN 123 *****
BASH is awesome
***** END *****
***** BEGIN 365 *****
KSH is awesome
***** END *****
***** BEGIN 157 *****
KSH is awesome
***** END *****
***** BEGIN 7123 *****
C is awesome
***** END *****
I am trying to find all... (4 Replies)
Discussion started by: reldb
4 Replies
LEARN ABOUT SUSE
log::log4perl::level
Level(3) User Contributed Perl Documentation Level(3)
NAME
Log::Log4perl::Level - Predefined log levels
SYNOPSIS
use Log::Log4perl::Level;
print $ERROR, "
";
# -- or --
use Log::Log4perl qw(:levels);
print $ERROR, "
";
DESCRIPTION
"Log::Log4perl::Level" simply exports a predefined set of Log4perl log levels into the caller's name space. It is used internally by
"Log::Log4perl". The following scalars are defined:
$OFF
$FATAL
$ERROR
$WARN
$INFO
$DEBUG
$TRACE
$ALL
"Log::Log4perl" also exports these constants into the caller's namespace if you pull it in providing the ":levels" tag:
use Log::Log4perl qw(:levels);
This is the preferred way, there's usually no need to call "Log::Log4perl::Level" explicitely.
The numerical values assigned to these constants are purely virtual, only used by Log::Log4perl internally and can change at any time, so
please don't make any assumptions.
If the caller wants to import these constants into a different namespace, it can be provided with the "use" command:
use Log::Log4perl::Level qw(MyNameSpace);
After this $MyNameSpace::ERROR, $MyNameSpace::INFO etc. will be defined accordingly.
Numeric levels and Strings
Level variables like $DEBUG or $WARN have numeric values that are internal to Log4perl. Transform them to strings that can be used in a
Log4perl configuration file, use the c<to_level()> function provided by Log::Log4perl::Level:
use Log::Log4perl qw(:easy);
use Log::Log4perl::Level;
# prints "DEBUG"
print Log::Log4perl::Level::to_level( $DEBUG ), "
";
To perform the reverse transformation, which takes a string like "DEBUG" and converts it into a constant like $DEBUG, use the to_priority()
function:
use Log::Log4perl qw(:easy);
use Log::Log4perl::Level;
my $numval = Log::Log4perl::Level::to_priority( "DEBUG" );
after which $numval could be used where a numerical value is required:
Log::Log4perl->easy_init( $numval );
COPYRIGHT AND LICENSE
Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess <cpan@goess.org>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.12.1 2010-02-07 Level(3)