Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Displaying field of NR, not the line # Post 302740769 by markymarkg123 on Thursday 6th of December 2012 06:12:06 PM
Old 12-06-2012
Displaying field of NR, not the line #

Within AWK, how do you display a field of NR? Here's my code:

Code:
awk '(NR>1) && (P1=$1-w)>=100000 {print "increase of" " " P1*.0000179," " "kW at" " " 'NR*60/431900' " " "minutes" "\n" "change from" " " 'NR-10($1)' " " "kW to" " " 'NR+70($1)' "\n"}{w=$1}' filename

I can change NR and print line #'s, but cannot get a field to print...the error comes at the segment
Code:
'NR-10($1)' " " "kW to" " " 'NR+70($1)'

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

displaying the first line?

how do i display just the first line of a file with the cat command or any command for that matter (4 Replies)
Discussion started by: imuuk
4 Replies

2. UNIX for Dummies Questions & Answers

displaying the last line of the file

hi... i need to display the last line of the file and capture the line in to a variable in unix envt.(not the perl ones)... please help (8 Replies)
Discussion started by: lmadhuri
8 Replies

3. Shell Programming and Scripting

Displaying lines of a file where the second field matches a pattern

Howdy. I know this is most likely possible using sed or awk or grep, most likely a combination of them together, but how would one go about running a grep like command on a file where you only try to match your pattern to the second field in a line, space delimited? Example: You are... (3 Replies)
Discussion started by: LordJezoX
3 Replies

4. Shell Programming and Scripting

Displaying a field completely

Version: AIX 6.1 (korn shell) In the below output, the field with the heading 'Address' has some names like hwproc214-priv1.gnas.wrd.netwhich are only partially displayed. $ netstat -i Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll en2 1500 link#2 ... (3 Replies)
Discussion started by: polavan
3 Replies

5. Shell Programming and Scripting

Compare Field in Current Line with Field in Previous

Hi Guys I have the following file Essentially, I am trying to find the right awk/sed syntax in order to produce the following 3 distinct files from the file above: Basically, I want to print the lines of the file as long as the second field of the current line is equal to the... (9 Replies)
Discussion started by: moutaye
9 Replies

6. Shell Programming and Scripting

sed to replace a field from a line with another field

i have something like this, cat filename.txt hui this si s"dfgdfg" omeone ipaddress="10.19.123.104" wel hope this works i want to replace only 10.19.123.104 with different ip say 10.19.123.103 i tried this sed -i "s/'ipaddress'/'ipaddress=10.19.123.103'/g" filename.txt ... (1 Reply)
Discussion started by: vivek d r
1 Replies

7. Shell Programming and Scripting

Displaying the first field if the second field matches the pattern using Perl

Hi, I am trying with the below Perl command to print the first field when the second field matches the given pattern: perl -lane 'open F, "< myfile"; for $i (<F>) {chomp $i; if ($F =~ /patt$/) {my $f = (split(" ", $i)); print "$f";}} close F' dummy_file I know I can achieve the same with the... (7 Replies)
Discussion started by: royalibrahim
7 Replies

8. Red Hat

Displaying command return in one line

Hello all I have a query (SQL) that returns a rather long field from an Oracle database. The field in question is defined on 400 characters but all these 400 cannot be displayed by the echo command. Thus when I launch the following command: echo "SELECT FIELD01 FROM TABLE_NAME;" | sqlplus -s... (9 Replies)
Discussion started by: S. BASU
9 Replies

9. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

10. UNIX for Beginners Questions & Answers

Displaying every other line in an array.

Hi, I have an array, that works well. But, I want to have it display every other line. Like so, 1, 3, 5, 7, etc, etc. Here is the relevant code: I'm sorry for the pastebin link. For some reason, I can't get the code to format properly with the code tags. code tags work fine... everyone... (4 Replies)
Discussion started by: ignatius
4 Replies
Graphics::Primitive::Insets(3pm)			User Contributed Perl Documentation			  Graphics::Primitive::Insets(3pm)

NAME
Graphics::Primitive::Insets - Space between things DESCRIPTION
Graphics::Primitive::Insets represents the amount of space that surrounds something. This object can be used to represent either padding or margins (in the CSS sense, one being inside the bounding box, the other being outside) SYNOPSIS
use Graphics::Primitive::Insets; my $insets = Graphics::Primitive::Insets->new({ top => 5, bottom => 5, left => 5, right => 5 }); METHODS
Constructor new Creates a new Graphics::Primitive::Insets. Instance Methods as_array Return these insets as an array in the form of top, right, bottom and left. bottom Set/Get the inset from the bottom. equal_to Determine if these Insets are equal to another. left Set/Get the inset from the left. right Set/Get the inset from the right. top Set/Get the inset from the top. zero Sets all the insets (top, left, bottom, right) to 0. AUTHOR
Cory Watson, "<gphat@cpan.org>" SEE ALSO
perl(1) COPYRIGHT &; LICENSE Copyright 2008-2010 by Cory G Watson. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2010-08-21 Graphics::Primitive::Insets(3pm)
All times are GMT -4. The time now is 04:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy