Sponsored Content
Full Discussion: line count
Top Forums Shell Programming and Scripting line count Post 302446219 by j_panky on Wednesday 18th of August 2010 04:40:06 AM
Old 08-18-2010
iam not...that means there is some other way to do it....
My files is a huge file...
need to know the exact line count...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the line count from 2nd line of the file ?

Hi, I want to get the line count of the file from the 2nd line of the file ? The first line is header so want to skip that. Thanks. (8 Replies)
Discussion started by: smc3
8 Replies

2. UNIX for Dummies Questions & Answers

Count on every other line

I'd like to create a loop that will display something like: 1 2 29 2 57 2 ... 25173 2 I figure I'd want to make some code that counts to 1798 and for the odd numbers displays: 1+28((n-1)/2) and for the even numbers displays 2. This is what I wrote:#! /bin/csh #include <stdio.h> int... (4 Replies)
Discussion started by: red baron
4 Replies

3. Shell Programming and Scripting

Append line count to each line

Hello forum, I need to append the total line count to the end of each line in a file. The file where this line count needs to be appended is generated by this script: The script does a word frequency count by the first column of a file. if I add wc -l at the end then the line count... (4 Replies)
Discussion started by: jaysean
4 Replies

4. Shell Programming and Scripting

Line count

Hello friends, Could you please help on this, n=`wc -l test.txt` echo $n the above two line code give me "67 text.txt" where as i just need n= 67 as line count (3 Replies)
Discussion started by: Danish Shakil
3 Replies

5. Shell Programming and Scripting

Shell script to count number of ~ from each line and compare with next line

Hi, I have created one shell script in which it will count number of "~" tilda charactors from each line of the file.But the problem is that i need to count each line count individually, that means. if line one contains 14 "~"s and line two contains 15 "~"s then it should give an error msg.each... (3 Replies)
Discussion started by: Ganesh Khandare
3 Replies

6. Shell Programming and Scripting

Delimiter Count Line by Line

Hi All, I have totally 10 source files. I want to count the delimiter In my source files line by line and need to store the result in another file. I got the output for the total count of delimiter for one file. But I am struggling to get the delimiter count line by line for each my files. Plz... (6 Replies)
Discussion started by: suresh01_apk
6 Replies

7. Shell Programming and Scripting

line count

Hi In my directory i have file of many days , i want to count the number of line of all the files of todays date. every file will have date component on it for eg. V5_T_RIO_TAFM_20120905070015847.LOG from the file name 20120905- > this show that file is of today's date . I have written... (8 Replies)
Discussion started by: guddu_12
8 Replies

8. Shell Programming and Scripting

Compare file1 header count with file2 line count

What I'm trying to accomplish. I receive a Header and Detail file for daily processing. The detail file comes first which holds data, the header is a receipt of the detail file and has the detail files record count. Before processing the detail file I would like to put a wrapper around another... (4 Replies)
Discussion started by: pone2332
4 Replies

9. Shell Programming and Scripting

Count the pipes "|" in line and delete line if count greter then number.

Hello, I have been working on Awk/sed one liner which counts the number of occurrences of '|' in pipe separated lines of file and delete the line from files if count exceeds "17". i.e need to get records having exact 17 pipe separated fields(no more or less) currently i have below : awk... (1 Reply)
Discussion started by: ketanraut
1 Replies

10. UNIX for Beginners Questions & Answers

Count pattern line by line

I have a file like below with more than 30,000 lines: Someword "mypattern blah blah mypattern blah mypattern blah " Someotherword "mypattern blah blah mypattern blah mypattern blah" Someword "mypattern blah blah blah mypattern blah " Someword "mypattern blah blah mypattern blah ... (3 Replies)
Discussion started by: ctrld
3 Replies
rl(1)								   User Commands							     rl(1)

NAME
rl - Randomize Lines. SYNOPSIS
rl [OPTION]... [FILE]... DESCRIPTION
rl reads lines from a input file or stdin, randomizes the lines and outputs a specified number of lines. It does this with only a single pass over the input while trying to use as little memory as possible. -c, --count=N Select the number of lines to be returned in the output. If this argument is omitted all the lines in the file will be returned in random order. If the input contains less lines than specified and the --reselect option below is not specified a warning is printed and all lines are returned in random order. -r, --reselect When using this option a single line may be selected multiple times. The default behaviour is that any input line will only be selected once. This option makes it possible to specify a --count option with more lines than the file actually holds. -o, --output=FILE Send randomized lines to FILE instead of stdout. -d, --delimiter=DELIM Use specified character as a "line" delimiter instead of the newline character. -0, --null Input lines are terminated by a null character. This option is useful to process the output of the GNU find -print0 option. -n, --line-number Output lines are numbered with the line number from the input file. -q, --quiet, --silent Be quiet about any errors or warnings. -h, --help Show short summary of options. -v, --version Show version of program. EXAMPLES
Some simple demonstrations of how rl can help you do everyday tasks. Play a random sound after 4 minutes (perfect for toast): sleep 240 ; play `find /sounds -name '*.au' -print | rl --count=1` Play the 15 most recent .mp3 files in random order. ls -c *.mp3 | head -n 15 | rl | xargs --delimiter=' ' play Roll a dice: seq 6 | rl --count 2 Roll a dice 1000 times and see which number comes up more often: seq 6 | rl --reselect --count 1000 | sort | uniq -c | sort -n Shuffle the words of a sentence: echo -n "The rain in Spain stays mainly in the plain." | rl --delimiter=' ';echo Find all movies and play them in random order. find . -name '*.avi' -print0 | rl -0 | xargs -n 1 -0 mplayer Because -0 is used filenames with spaces (even newlines and other unusual characters) in them work. BUGS
The program currently does not have very smart memory management. If you feed it huge files and expect it to fully randomize all lines it will completely read the file in memory. If you specify the --count option it will only use the memory required for storing the specified number of lines. Improvements on this area are on the TODO list. The program uses the rand() system random function. This function returns a number between 0 and RAND_MAX, which may not be very large on some systems. This will result in non-random results for files containing more lines than RAND_MAX. Note that if you specify multiple input files they are randomized per file. This is a different result from when you cat all the files and pipe the result into rl. COPYRIGHT
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Arthur de Jong. This is free software; see the license for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Version 0.2.7 Jul 2008 rl(1)
All times are GMT -4. The time now is 04:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy