Sponsored Content
Top Forums Shell Programming and Scripting awk - set numbers [ 1 ... n] from the 6 line Post 302964389 by RavinderSingh13 on Thursday 14th of January 2016 05:27:11 AM
Old 01-14-2016
Hello IMPe,

Request you to please always do show sample input and expected sample output too. If I understood correctly your requirement, could you please try following and let me know if that helps.
Code:
###If you want to leave empty line.
awk 'NR > 6 && NF{ print ++i "\t" $0 }'  Input_file
 
###If you want to count each line then following may help.
awk 'NR > 6 { print ++i "\t" $0 }'  Input_file

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

How to set constrain on random numbers in c

Hi, I am currently trying to generate multiple random numbers in C for different variable:- die1=1+(rand()%5); die2=1+(rand()%5); die3=1+(rand()%5); die4=1+(rand()%5); But I need to contrain the total of die1, die2,die3 and die4 to be 5 as well. If i insert die1+die2+die3+die4=5, i do... (6 Replies)
Discussion started by: ahjiefreak
6 Replies

2. UNIX for Advanced & Expert Users

Add line numbers to end of each line

Hi i would like to add line numbers to end of each line in a file. I am able to do it in the front of each line using sed, but not able to add at the end of the file. Can anyone suggest The following code adds line number to start of each line sed = filename | sed 'N;s/\n/\t/' how can i... (5 Replies)
Discussion started by: rudoraj
5 Replies

3. UNIX for Dummies Questions & Answers

seperating records with numbers from a set of numbers

I have two files one (numbers file)contains the numbers(approximately 30000) and the other file(record file) contains the records(approximately 40000)which may or may not contain the numbers from that file. I want to seperate the records which has the field 1=(any of the number from numbers... (15 Replies)
Discussion started by: Shiv@jad
15 Replies

4. Shell Programming and Scripting

How to take set of numbers?

I have to take a list of numbers from the keyboard and not by passing arguments. How will I read a set of numbers in such a way that I can use any number I wish to operate upon. Is there any specific command to do so. As said before I dont want to pass the numbers as arguments from command line.... (3 Replies)
Discussion started by: VishBoy
3 Replies

5. Shell Programming and Scripting

Assign Line Numbers to each line of the file

Hi! I'm trying to assign line numbers to each line of the file for example consider the following.. The contents of the input file are hello how are you? I'm fine. How about you? I'm trying to get the following output.. 1 hello how are you? 2 I'm fine. 3 How about you? ... (8 Replies)
Discussion started by: abk07
8 Replies

6. Shell Programming and Scripting

Compute the median of a set of numbers with AWK?

Is there a way in awk to compute the median of a set of numbers in a file in the following format. 34 67 78 100 23 45 67 (3 Replies)
Discussion started by: Lucky Ali
3 Replies

7. Shell Programming and Scripting

awk command to compare a file with set of files in a directory using 'awk'

Hi, I have a situation to compare one file, say file1.txt with a set of files in directory.The directory contains more than 100 files. To be more precise, the requirement is to compare the first field of file1.txt with the first field in all the files in the directory.The files in the... (10 Replies)
Discussion started by: anandek
10 Replies

8. Shell Programming and Scripting

awk script to filter the numbers which are around the set value

Hi All, I have one sensor output(over the same) for a set value of 20. Time(in Sec), Data 1, 16 2, 20 3, 24 4, 22 5, 21 6, 20 7, 19.5 8, 20 9, 20.5 10, 20 11, 20 12, 19.5 Here we can see like after 5 sec of time the data value reaches to 20+-0.5 range. So I... (7 Replies)
Discussion started by: ks_reddy
7 Replies

9. Shell Programming and Scripting

awk : Filter a set of data to parse header line and last field of multiple same match.

Hi Experts, I have a data with multiple entry , I want to filter PKG= & the last column "00060110" or "00088150" in the output file: ############################################################################################### PKG= P8SDB :: VGS = vgP8SOra vgP8SDB1 vgP8S001... (5 Replies)
Discussion started by: rveri
5 Replies

10. Shell Programming and Scripting

Efficient awk way to add numbers in line fields

data.now: blah1,dah,blaha,sweet,games.log,5297484456,nagios-toin,529748456,on__host=93 SERVICE__ALERT_=51 Warning___The__results__of__service=16 Warning___on__host=92 Auto_save__of__retention__data__completed=1 Warning___Return=68 PASSIVE__SERVICE__CHECK_=53 ,1026--1313,1... (12 Replies)
Discussion started by: SkySmart
12 Replies
sip_enable_counters(3SIP)			   Session Initiation Protocol Library Functions			 sip_enable_counters(3SIP)

NAME
sip_enable_counters, sip_disable_counters, sip_get_counter_value - counter operations SYNOPSIS
cc [ flag... ] file... -lsip [ library... ] #include <sip.h> int sip_enable_counters(int counter_group); int sip_disable_counters(int counter_group); int sip_get_counter_value(int group, int counter, void *counterval, size_t counterlen); DESCRIPTION
The sip_enable_counters() function enables the measurement and counting of the selected counter group. The only allowed value for the counter_group is SIP_TRAFFIC_COUNTERS, which is defined in <sip.h>. Once enabled, the SIP stack starts measuring end-to-end SIP traffic. The SIP stack keeps track of: o the number of SIP requests sent and received (broken down by methods), o the number of SIP responses sent and received (broken down by response codes), and o the number of bytes sent and received. The following counters are defined in <sip.h> for the SIP_TRAFFIC_COUNTERS group. These counter values are retrieved using the sip_get_counter_value() function. SIP_TOTAL_BYTES_RCVD SIP_TOTAL_BYTES_SENT SIP_TOTAL_REQ_RCVD SIP_TOTAL_REQ_SENT SIP_TOTAL_RESP_RCVD SIP_TOTAL_RESP_SENT SIP_ACK_REQ_RCVD SIP_ACK_REQ_SENT SIP_BYE_REQ_RCVD SIP_BYE_REQ_SENT SIP_CANCEL_REQ_RCVD SIP_CANCEL_REQ_SENT SIP_INFO_REQ_RCVD SIP_INFO_REQ_SENT SIP_INVITE_REQ_RCVD SIP_INVITE_REQ_SENT SIP_NOTIFY_REQ_RCVD SIP_NOTIFY_REQ_SENT SIP_OPTIONS_REQ_RCVD SIP_OPTIONS_REQ_SENT SIP_PRACK_REQ_RCVD SIP_PRACK_REQ_SENT SIP_REFER_REQ_RCVD SIP_REFER_REQ_SENT SIP_REGISTER_REQ_RCVD SIP_REGISTER_REQ_SENT SIP_SUBSCRIBE_REQ_RCVD SIP_SUBSCRIBE_REQ_SENT SIP_UPDATE_REQ_RCVD SIP_UPDATE_REQ_SENT SIP_1XX_RESP_RCVD SIP_1XX_RESP_SENT SIP_2XX_RESP_RCVD SIP_2XX_RESP_SENT SIP_3XX_RESP_RCVD SIP_3XX_RESP_SENT SIP_4XX_RESP_RCVD SIP_4XX_RESP_SENT SIP_5XX_RESP_RCVD SIP_5XX_RESP_SENT SIP_6XX_RESP_RCVD SIP_6xx_RESP_SENT SIP_COUNTER_START_TIME /* records time when counting was enabled */ SIP_COUNTER_STOP_TIME /* records time when counting was disabled */ All of the above counters are defined to be uint64_t, except for SIP_COUNTER_START_TIME and SIP_COUNTER_STOP_TIME, which are defined to be time_t. The sip_disable_counters() function disables measurement and counting for the specified counter_group. When disabled, the counter values are not reset and are retained until the measurement is enabled again. Calling sip_enable_counters() again would reset all counter values to zero and counting would start afresh. The sip_get_counter_value() function retrieves the value of the specified counter within the specified counter group. The value is copied to the user provided buffer, counterval, of length counterlen. For example, after the following call, invite_rcvd would have the correct value. uint64_t invite_rcvd; sip_get_counter_value(SIP_TRAFFIC_COUNTERS, SIP_INVITE_REQ_RCVD, &invite_rcvd, sizeof (uint64_t)); RETURN VALUES
Upon successful completion, sip_enable_counters() and sip_disable_counters() return 0. They will return EINVAL if an incorrect group is specified. Upon successful completion, sip_get_counter_value() returns 0. It returns EINVAL if an incorrect counter name or counter size is speci- fied, or if counterval is NULL. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.11 11 Jan 2008 sip_enable_counters(3SIP)
All times are GMT -4. The time now is 08:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy