Sponsored Content
Full Discussion: How to find line number?
Top Forums Shell Programming and Scripting How to find line number? Post 302845635 by Prashanth B on Thursday 22nd of August 2013 03:20:55 AM
Old 08-22-2013
How to find line number?

I have a data file (which has five columns) from which im finding column count of all the records and writing into separate file say "colcnt.txt". And I find one (or more) records have less column counts (i.e split records). I need to know which record(s) have that split scenario. Is there any way to find out line number from data file which has split records ?

Code:
Datafile.txt
1,abc,mon,589,hi
2,qwe,tue,456,bye
3,mnb,wed,145,pppp
4,asd,thurs
5,lkj,fri,675,hhhh
 
colcnt.txt
5
5
5
3
5
 
Output-
Line number : 4 has less number of columns which is a split record.

Thanks in Advance..!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script to find the number of tab delimiters in a line

Hi, I need to find the number of tab delimiters in the first line of a file.So using word=`head -1 files.txt` I have extracted the first line of file into a variable word.It has 20 tab delimted columns.So can anyone help me in finding the number of delimiters? I am using csh and I am a... (5 Replies)
Discussion started by: poornimajayan
5 Replies

2. Shell Programming and Scripting

how to find the line number of a pattern of first appearance??

Hi, I am doin a project in shell script please answer the above question..... waiting........ (2 Replies)
Discussion started by: shivarajM
2 Replies

3. Shell Programming and Scripting

to find the number from a line.

Hi, I need to write a script which will have a text string as a input and the output should find out the number in the text string and add one to it. Eg: Input => asfdosainovih1234lnsiohn Output => 1235 All the numbers in the text will be together and only one time in the line. ... (2 Replies)
Discussion started by: vikings.svnit
2 Replies

4. Shell Programming and Scripting

find out line number of matching string using grep

Hi all, I want to display line number for matching string in a file. can anyone please help me. I used grep -n "ABC" file so it displays 6 ABC. But i only want to have line number,i don't want that it should prefix matching context with line number. Actually my original... (10 Replies)
Discussion started by: sarbjit
10 Replies

5. Shell Programming and Scripting

Take each number in table row and find the difference from the corresponding line

I have a two files containing numbers like below. First one contains one number on each line, the other is a table of numbers, each separated by a space. There are the same number of lines in each file. I want to take each number in the row of the table and find the difference from the... (12 Replies)
Discussion started by: kristinu
12 Replies

6. Shell Programming and Scripting

Find line number of bad data in large file

Hi Forum. I was trying to search the following scenario on the forum but was not able to. Let's say that I have a very large file that has some bad data in it (for ex: 0.0015 in the 12th column) and I would like to find the line number and remove that particular line. What's the easiest... (3 Replies)
Discussion started by: pchang
3 Replies

7. Shell Programming and Scripting

How do i find the first number in each line and insert dummy string into the missing columns?

Hi, I have one input file with the following content: MY_inpfile.txt Aname1 Cname1 Cname2 1808 5 Aname2 Cname1 1802 47 Bname1 ? 1819 22 Bname2 Cname1 1784 11 Bname3 1817 9 Zname1 Cname1 1805 59 Zname2 Cname1 Cname2 Cname3 1797 27 Every line in my input file have a 4 digit... (5 Replies)
Discussion started by: Szaffy
5 Replies

8. Shell Programming and Scripting

Find line number

How to find a line number? I have a file: 1 5 8 9 10 15 Is there a simple method to find out on which line for example the 9 is written? (3 Replies)
Discussion started by: jds93
3 Replies

9. Shell Programming and Scripting

awk to find number in a field then print the line and the number

Hi I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field. The source file is pipe delimited and looks something like 1|net|ABC Letr1|1530||| 1|net|EXP_1040 ABC|1121||| 1|net|EXP_TG1224|1122||| 1|net|R_North|1123|||... (5 Replies)
Discussion started by: Mudshark
5 Replies

10. UNIX for Beginners Questions & Answers

How to find encapsulating function name from line number?

I am looking at a log file which just tells me the filename and the line number inside that file that has the Error. What I am interested is knowing the encapsulating function. For example, here are the contents of the log file Error: foo.file on line wxy Error: foo.file... (3 Replies)
Discussion started by: kaaliakahn
3 Replies
MINMAX(l)																 MINMAX(l)

NAME
minmax - Find extreme values in data tables SYNOPSIS
minmax [ files] [ -C ] [ -D ] [ -H[nrec] ] [ -Idx[/dy] ] [ -L ] [ -M[flag] ] [ -: ] [ -bi[s][n] ] DESCRIPTION
minmax reads its standard input [or from files] and finds the extreme values in each of the columns. It recognizes NaNs and will print warnings if the number of columns vary from record to record. As an option, minmax will find the extent of the first two columns rounded up and down to the nearest multiple of dx/dy. This output will be in the form -Rw/e/s/n which can be used directly in the command line for other programs, or simply in column form. xyzfile ASCII [or binary, see -b] file(s) holding a fixed number of data columns. OPTIONS
-C Report the min/max values per column in separate columns [Default uses <min/max> format] -D Sets longitude discontinuity to the Dateline (-180/+180) [Default is Greenwich (0-360)]. Requires -L. -H Input file(s) has Header record(s). Number of header records can be changed by editing your .gmtdefaults file. If used, GMT default is 1 header record. -I Report the min/max of the first two columns to the nearest multiple of dx and dy, and output this in the form -Rw/e/s/n (unless -C is set). -L Indicates that the x column contains longitudes, which may be periodic in 360 degrees [Default assumes no periodicity]. -M Multiple segment file(s). Segments are separated by a special record. For ASCII files the first character must be flag [Default is '>']. For binary files all fields must be NaN. -: Toggles between (longitude,latitude) and (latitude,longitude) input/output. [Default is (longitude,latitude)]. Applies to geo- graphic coordinates only. Only works when -I is selected. -bi Selects binary input. Append s for single precision [Default is double]. Append n for the number of columns in the binary file(s). [Default is 2 input columns]. EXAMPLES
To find the extreme values in the file ship_gravity.xygd, try minmax ship_gravity.xygd Output should look like ship_gravity.xygd: N = 6992 <326.125/334.684> <-28.0711/-8.6837> <-47.7/177.6> <0.6/3544.9> To find the extreme values in the file track.xy to the nearest 5 units and use this region to draw a line using psxy, try psxy `minmax -I5 track.xy` track.xy -Jx1 -B5 -P > track.ps To find the min and max values for each column, but rounded to integers, try minmax junkfile -C -I1 SEE ALSO
gmt(1gmt) 1 Jan 2004 MINMAX(l)
All times are GMT -4. The time now is 07:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy