Sponsored Content
Operating Systems HP-UX Script to identify the line number containing a particular "string" Post 302373993 by kk2202 on Monday 23rd of November 2009 05:31:34 AM
Old 11-23-2009
Script to identify the line number containing a particular "string"

Hi,

I have a log file, where i am required to identify the line number, where a particular string/line appears in the log file.

And then copy 200 lines above that line number to a new file.

Can someone provide pointers on how to write this script or what command to be used ?

Any help would be highly appreciated.


Thanks in advnace,
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

Shell Script to identify the line number containing a particular "string"

Hi, I have a log file, where i am required to identify the line number, where a particular string/line appears in the log file. And then copy 200 lines above that line number to a new file. Can someone provide pointers on how to write this script or what command to be used ? Any... (2 Replies)
Discussion started by: kk2202
2 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

5. Shell Programming and Scripting

Deleting "user input line number" from a file using sed

Hi I want to delete a line from a txt file for which the line number is user input. Say when user selects 19, the 19th line would be deleted from the file. Can anyone please provide me with a sed one liner for the same... I tried sed -i. The interaction would be like this Enter the line... (4 Replies)
Discussion started by: sudeep.id
4 Replies

6. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

7. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

8. Shell Programming and Scripting

Failure: if grep "$Var" "$line" inside while read line loop

Hi everybody, I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o My code: #!/bin/sh set -e set -u export IFS= optl="Optl" LOCSTORCLI="/opt/lsi/storcli/storcli" ($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
Discussion started by: Subsonic66
5 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

10. Programming

Python : Problem with " TypeError: float() argument must be a string or a number "

Hello ! I'm creating a CGI which allow to display graph from some data. The datas looks like : 2020-01-13-00-00,384.00,350.00 2020-01-13-06-00,384.00,350.00 2020-01-13-12-00,384.00,350.00 2020-01-13-18-00,384.00,350.00 2020-01-14-00-00,384.00,350.00... (1 Reply)
Discussion started by: Tim2424
1 Replies
DPKG::Log::Entry(3pm)					User Contributed Perl Documentation				     DPKG::Log::Entry(3pm)

NAME
DPKG::Log::Entry - Describe a log entry in a dpkg.log VERSION
version 1.20 SYNOPSIS
use DPKG::Log::Entry; $dpkg_log_entry = DPKG::Log::Entry->new( line => $line, $lineno => 1) $dpkg_log_entry->timestamp($dt); $dpkg_log_entry->associated_package("foo"); DESCRIPTION
This module is used to describe one line in a dpkg log by parameterizing every line into generic parameters like o Type of log entry (startup-, status-, action-lines) o Timestamp o Subject of log entry (e.g. package, packages or archives) o Package name (if log entry refers to a package subject) and so on. The various parameters are described below together with the various methods to access or modify them. METHODS
$dpkg_log_entry = PACKAGE->new( 'line' => $line, 'lineno' => $lineno ) Returns a new DPKG::Log::Entry object. The arguments line and lineno are mandatore. They store the complete line as stored in the log and the line number. Additionally its possible to specify every attribute the object can store, as 'key' => 'value' pairs. ATTRIBUTES
$dpkg_log_entry->line() / line Return the full log line. This attribute is set on object initialization. $dpkg_log_entry->lineno() / lineno Return the line number of this entry. This attribute is set on object initialization. $dpkg_log_entry->timestamp() / timestamp Get or set the timestamp of this object. Should be a DateTime object. $dpkg_log_entry->type() / type Get or set the type of this entry. Specifies weither this is a startup, status or action line. $dpkg_log_entry->associated_package() / associated_package Get or set the associated_package of this entry. This is for lines that are associated to a certain package like in action or status lines. Its usually unset for startup and status lines. $dpkg_log_entry->action() / action Get or set the action of this entry. This is for lines that have a certain action, like in startup-lines (unpack, configure) or action lines (install, remove). It is usally unset for status lines. $dpkg_log_entry->status() / status Get or set the status of the package this entry refers to. $dpkg_log_entry->subject() / subject Gets or Defines the subject of the entry. For startup lines this is usually 'archives' or 'packages' for all other lines its 'package'. $dpkg_log_entry->installed_version() / installed_version Gets or Defines the installed_version of the package this entry refers to. It refers to the current installed version of the package depending on the current status. Is "<none>" (or similar) if action is 'install', old version in case of an upgrade. $dpkg_log_entry->available_version() / available_version Gets or Defines the available_version of the package this entry refers to. It refers to the currently available version of the package depending on the current status. Is different from installed_version if the action is install or upgrade. $dpkg_log_entry->conffile() / conffile Get or set a conffile for a line indicating a conffile change. $dpkg_log_entry->decision() / decision Gets or defines the decision for a line indicating a conffile change. SEE ALSO
DateTime AUTHOR
Patrick Schoenfeld <schoenfeld@debian.org>. COPYRIGHT AND LICENSE
Copyright (C) 2011 Patrick Schoenfeld <schoenfeld@debian.org> This library is free software. You can redistribute it and/or modify it under the same terms as perl itself. perl v5.10.1 2011-02-23 DPKG::Log::Entry(3pm)
All times are GMT -4. The time now is 01:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy