Sponsored Content
Top Forums Shell Programming and Scripting Extracting specific lines of data from a file and related lines of data based on a grep value range? Post 302523299 by Wynner on Wednesday 18th of May 2011 10:38:04 AM
Old 05-18-2011
Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi,
I have one file, say file 1, that has data like below where 19900107 is the date,

19900107 12 144 129 0.7380047
19900108 12 168 129 0.3149017
19900109 12 192 129 3.2766666E-02
19900110 12 216 129 -2.0089082E-02
19900111 12 240 129 -0.3891007
19900107 12 120 151 0.8195071

I want to extract all info from this file , and send it to file 2, that has a line with "240" and a value at the end between 0.8 and 1. Any line that matches this criteria i also want to extract the previous 5 lines of data (i.e. the previous 5 dates). All any any help is appreciated. I'm a new linux user. Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Writing data onto new lines based on terminator

I have a requirement, where based on a particular character on a single line, the data has to be written to new lines... Ex: abccd$xyzll$bacc$kkklkjl$albc My output should be abccd$ xyzll$ bacc$ kkklkjl$ albc Can someone help on this. (1 Reply)
Discussion started by: thanuman
1 Replies

2. Shell Programming and Scripting

extracting specific lines from a file

hi all, i searched in unix.com and accquired the following commands for extracting specific lines from a file .. sed -n '16482,16482p' in.sql > out.sql awk 'NR>=10&&NR<=20' in.sql > out.sql.... these commands are working fine if i give the line numbers as such .. but if i pass a... (2 Replies)
Discussion started by: sais
2 Replies

3. Shell Programming and Scripting

insert data into specific lines of a CSV

So I work in a 1 to 1 laptop deployment and sometimes we need to mass order parts. The vendor will send us a text file and we have to manually input serial numbers. Well I have a full blown web based inventory system which I can pull serial number reports from. I then have to input the part... (4 Replies)
Discussion started by: tlarkin
4 Replies

4. Shell Programming and Scripting

Extracting high frequency data-lines

Hi, I have a very large log file in the following format: 198.28.0.0 - - 200 348 244.48.0.0 - - 200 211 198.28.0.0 - - 200 191 4.48.0.0 - - 200 1131 244.48.0.0 - - 200 1131 244.48.0.0 - - 200 1131 4.48.0.0 - - 200 1131 244.48.0.0 - - 200 211 4.48.0.0 - - 200 1131 ... (2 Replies)
Discussion started by: sajal.bhatia
2 Replies

5. Shell Programming and Scripting

Search for a specific data in a file based on a date range

Hi, Currently I am working on a script to automate the process of converting the log file from binary into text format. To achieve this, partly I am depending on my application’s utility for this conversion and the rest I am relying on shell commands to search for directory, locate the file and... (5 Replies)
Discussion started by: svajhala
5 Replies

6. UNIX for Dummies Questions & Answers

how to write a function to get data under specific lines ?

I have a text file called (msgz ) contains data : Subscriber Data ID = 2 Customer = 99 Data ID = 4 Customer = cf99 Data ID = 5 Customer = c99 Data ID = 11 Customer = 9n9 Subscriber Data ID = 1 Customer = 9ds9 Data ID = 2 Customer = 9sad9 Data ID = 3 Customer = f99... (3 Replies)
Discussion started by: teefa
3 Replies

7. UNIX for Dummies Questions & Answers

Filtering data -extracting specific lines

I have a table to data which one of the columns include string of text from within that, I am searching to include few lines but not others for example I want to to include some combination of word address such as (address.| address? |the address | your address) but not (ip address | email... (17 Replies)
Discussion started by: A-V
17 Replies

8. UNIX for Advanced & Expert Users

Extracting specific lines from data file

Hello, Is there a quick awk one-liner for this extraction?: file1 49389 text55 52211 text66 file2 59302 text1 49389 text2 85939 text3 52211 text4 13948 text5 Desired output 49389 text2 52211 text4 Thanks!! (5 Replies)
Discussion started by: palex
5 Replies

9. UNIX for Dummies Questions & Answers

Extracting data between specific lines, multiple times

I need help extracting specific lines in a text file. The file looks like this: POSITION TOTAL-FORCE (eV/Angst) ----------------------------------------------------------------------------------- 1.86126 1.86973 1.86972 ... (14 Replies)
Discussion started by: captainalright
14 Replies

10. Shell Programming and Scripting

Extracting data from multiple lines

Hi All, I am stuck in one step.. I have one file named file.txt having content: And SGMT.perd_id = (SELECT cal.fiscal_perd_id FROM $ODS_TARGT.TIM_DT_CAL_D CAL FROM $ODS_TARGT.GL_COA_SEGMNT_XREF_A SGMT SGMT.COA_XREF_TYP_IDN In (SEL COA_XREF_TYP_IDN From... (4 Replies)
Discussion started by: Shilpi Gupta
4 Replies
Smokeping_probes_OpenSSHJunOSPing(3)				     SmokePing				      Smokeping_probes_OpenSSHJunOSPing(3)

NAME
Smokeping::probes::OpenSSHJunOSPing - Juniper SSH JunOS Probe for SmokePing SYNOPSIS
*** Probes *** +OpenSSHJunOSPing forks = 5 offset = 50% packetsize = 100 step = 300 timeout = 15 # The following variables can be overridden in each target section junospass = password # mandatory junosuser = user # mandatory pings = 5 psource = 192.168.2.129 source = 192.168.2.1 # mandatory # [...] *** Targets *** probe = OpenSSHJunOSPing # if this should be the default probe # [...] + mytarget # probe = OpenSSHJunOSPing # if the default probe is something else host = my.host junospass = password # mandatory junosuser = user # mandatory pings = 5 psource = 192.168.2.129 source = 192.168.2.1 # mandatory DESCRIPTION
Connect to Juniper JunOS via OpenSSH to run ping commands. This probe uses the "extended ping" of the Juniper JunOS. You have the option to specify which interface the ping is sourced from as well. VARIABLES
Supported probe-specific variables: forks Run this many concurrent processes at maximum Example value: 5 Default value: 5 offset If you run many probes concurrently you may want to prevent them from hitting your network all at the same time. Using the probe- specific offset parameter you can change the point in time when each probe will be run. Offset is specified in % of total interval, or alternatively as 'random', and the offset from the 'General' section is used if nothing is specified here. Note that this does NOT influence the rrds itself, it is just a matter of when data acqusition is initiated. (This variable is only applicable if the variable 'concurrentprobes' is set in the 'General' section.) Example value: 50% packetsize The (optional) packetsize option lets you configure the packetsize for the pings sent. Default value: 100 step Duration of the base interval that this probe should use, if different from the one specified in the 'Database' section. Note that the step in the RRD files is fixed when they are originally generated, and if you change the step parameter afterwards, you'll have to delete the old RRD files or somehow convert them. (This variable is only applicable if the variable 'concurrentprobes' is set in the 'General' section.) Example value: 300 timeout How long a single 'ping' takes at maximum Example value: 15 Default value: 5 Supported target-specific variables: junospass The junospass option allows you to specify the password for the username specified with the option junosuser. Example value: password This setting is mandatory. junosuser The junosuser option allows you to specify a username that has ping capability on the JunOS Device. Example value: user This setting is mandatory. pings How many pings should be sent to each target, if different from the global value specified in the Database section. Note that the number of pings in the RRD files is fixed when they are originally generated, and if you change this parameter afterwards, you'll have to delete the old RRD files or somehow convert them. Example value: 5 psource The (optional) psource option specifies an alternate IP address or Interface from which you wish to source your pings from. Routers can have many many IP addresses, and interfaces. When you ping from a router you have the ability to choose which interface and/or which IP address the ping is sourced from. Specifying an IP/interface does not necessarily specify the interface from which the ping will leave, but will specify which address the packet(s) appear to come from. If this option is left out the JunOS Device will source the packet automatically based on routing and/or metrics. If this doesn't make sense to you then just leave it out. Example value: 192.168.2.129 source The source option specifies the JunOS device that is going to run the ping commands. This address will be used for the ssh connection. Example value: 192.168.2.1 This setting is mandatory. AUTHORS
Tobias Oetiker lttobi@oetiker.chgt based on Smokeping::probes::TelnetJunOSPing by S H A N ltshanali@yahoo.comgt. NOTES
JunOS configuration The JunOS device should have a username/password configured, as well as the ability to connect to the VTY(s). Make sure to connect to the remote host once from the commmand line as the user who is running smokeping. On the first connect ssh will ask to add the new host to its known_hosts file. This will not happen automatically so the script will fail to login until the ssh key of your juniper box is in the known_hosts file. Some JunOS devices have a maximum of 5 VTYs available, so be careful not to hit a limit with the 'forks' variable. Requirements This module requires the Net::OpenSSH and IO::Pty. 2.6.8 2013-03-17 Smokeping_probes_OpenSSHJunOSPing(3)
All times are GMT -4. The time now is 05:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy