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

Hi,

i have a file, where measurement-data is stored in the first column. The file has also a header of 5 lines. I want to set counting up numbers [1, 2, 3, ...] in front of any particular measurement-value; should start at the 6. line with starting number 1.
i try to solve it with ...
Code:
awk 'NR > 6 { print FNR "\t" $0 }' file.dat

..but it will cut the header. Can someone give me a hint, how to give out the complete file?

Thanks in advance,
IMPe
 

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
PR(1)								   User Commands							     PR(1)

NAME
pr - convert text files for printing SYNOPSIS
pr [OPTION]... [FILE]... DESCRIPTION
Paginate or columnate FILE(s) for printing. Mandatory arguments to long options are mandatory for short options too. +FIRST_PAGE[:LAST_PAGE], --pages=FIRST_PAGE[:LAST_PAGE] begin [stop] printing with page FIRST_[LAST_]PAGE -COLUMN, --columns=COLUMN output COLUMN columns and print columns down, unless -a is used. Balance number of lines in the columns on each page -a, --across print columns across rather than down, used together with -COLUMN -c, --show-control-chars use hat notation (^G) and octal backslash notation -d, --double-space double space the output -D, --date-format=FORMAT use FORMAT for the header date -e[CHAR[WIDTH]], --expand-tabs[=CHAR[WIDTH]] expand input CHARs (TABs) to tab WIDTH (8) -F, -f, --form-feed use form feeds instead of newlines to separate pages (by a 3-line page header with -F or a 5-line header and trailer without -F) -h, --header=HEADER use a centered HEADER instead of filename in page header, -h "" prints a blank line, don't use -h"" -i[CHAR[WIDTH]], --output-tabs[=CHAR[WIDTH]] replace spaces with CHARs (TABs) to tab WIDTH (8) -J, --join-lines merge full lines, turns off -W line truncation, no column alignment, --sep-string[=STRING] sets separators -l, --length=PAGE_LENGTH set the page length to PAGE_LENGTH (66) lines (default number of lines of text 56, and with -F 63) -m, --merge print all files in parallel, one in each column, truncate lines, but join lines of full length with -J -n[SEP[DIGITS]], --number-lines[=SEP[DIGITS]] number lines, use DIGITS (5) digits, then SEP (TAB), default counting starts with 1st line of input file -N, --first-line-number=NUMBER start counting with NUMBER at 1st line of first page printed (see +FIRST_PAGE) -o, --indent=MARGIN offset each line with MARGIN (zero) spaces, do not affect -w or -W, MARGIN will be added to PAGE_WIDTH -r, --no-file-warnings omit warning when a file cannot be opened -s[CHAR], --separator[=CHAR] separate columns by a single character, default for CHAR is the <TAB> character without -w and 'no char' with -w -s[CHAR] turns off line truncation of all 3 column options (-COLUMN|-a -COLUMN|-m) except -w is set -S[STRING], --sep-string[=STRING] separate columns by STRING, without -S: Default separator <TAB> with -J and <space> otherwise (same as -S" "), no effect on column options -t, --omit-header omit page headers and trailers -T, --omit-pagination omit page headers and trailers, eliminate any pagination by form feeds set in input files -v, --show-nonprinting use octal backslash notation -w, --width=PAGE_WIDTH set page width to PAGE_WIDTH (72) characters for multiple text-column output only, -s[char] turns off (72) -W, --page-width=PAGE_WIDTH set page width to PAGE_WIDTH (72) characters always, truncate lines, except -J option is set, no interference with -S or -s --help display this help and exit --version output version information and exit -t is implied if PAGE_LENGTH <= 10. With no FILE, or when FILE is -, read standard input. GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report pr translation bugs to <http://translationproject.org/team/> AUTHOR
Written by Pete TerMaat and Roland Huebner. COPYRIGHT
Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for pr is maintained as a Texinfo manual. If the info and pr programs are properly installed at your site, the com- mand info coreutils 'pr invocation' should give you access to the complete manual. GNU coreutils 8.22 June 2014 PR(1)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy