12-11-2003
Hi,
Counting lines inside a file and counting lines inside a file on tape are two different thing.
First of all, if you have a plain text-file you can do this using "wc -l"
F.E. : cat /var/adm/messages | wc -l >>/tmp/lines
This will count the number of lines from de messages file and <strong>appends</strong> this number to the file /tmp/lines
looking on tape depends on how you saved it. "tar tvf /dev/rtp", might tell you the files that are on the tape, but no garantuee. fining out the number of lines per file can only be done when restoring the file. At least for as far as I know. Maybe we can help a little more on this if we get to know the backup tool and method.
Regs David
10 More Discussions You Might Find Interesting
1. Linux
Hello,
I have afile which begins with a few urls on multiple lines and then there is listing of some information on separate lines.
The listing begins with the word Name on a given line followed by teh actual list.
I want to count the number of lines in this file after the line having... (6 Replies)
Discussion started by: nayeemmz
6 Replies
2. Shell Programming and Scripting
Hi there,
I have a couple of files I need to merge. I can do a simple merge by concatenating them into one larger file.
But then I need to filter the file to get a desired result.
The output looks like this:
TRNH 0000000010941
ORDH
OADR
OADR
ORDL
ENDT 1116399 000000003... (2 Replies)
Discussion started by: Meert
2 Replies
3. Shell Programming and Scripting
i have two file.
i want to count the lines of each file one by one in loop and compare it.
can any one pls help me on this? (1 Reply)
Discussion started by: Aditya.Gurgaon
1 Replies
4. Shell Programming and Scripting
Hi,
I have couple of .txt files (say 50 files) in a folder.
For each file:
I need to get the number of lines in each file and then that count -1 (I wanted to exclude the header.
Then sum the counts of all files and output the total sum.
Is there an efficient way to do this using shell... (7 Replies)
Discussion started by: Lucky Ali
7 Replies
5. Shell Programming and Scripting
Hi Guys,
I have a file as follows:
wwe
khfgv
jfo
wwe
jhgfd
wwe
wwe
hoaha
hao
lkahe
wwe (13 Replies)
Discussion started by: npatwardhan
13 Replies
6. Shell Programming and Scripting
Hi,
I have a little problem with counting lines. I know similar topics from this forum, but they don't resolve my problem. I have file with lines like this:
2009-05-25 16:55:32,143 some text some regular expressions ect.
2009-05-25 16:55:32,144 some text.
2009-05-28 18:15:12,148 some... (4 Replies)
Discussion started by: marcinnnn
4 Replies
7. Shell Programming and Scripting
Hi All,
I have a output that suppose to be like this (see below please)
App : Line counts
=== ==================
AAA: 100
BBB: 201
CCC: 137
DDD: 32
EEE: 55
for i in `ps -ef | grep App`; do print $i; done
This only shows
App :
=== (12 Replies)
Discussion started by: Beginer0705
12 Replies
8. UNIX for Advanced & Expert Users
I'm trying to write a script to clean up log file automatically when it reaches 1000 lines. I can't get this to work..can some help me please :)
Server: SunOS 5.8 Generic_117350-53 sun4u sparc SUNW,Netra-T12
#!/bin/ksh
#file reference
file=`echo "$HOME/support/moe/b.tc"`
#linecount... (7 Replies)
Discussion started by: moe458
7 Replies
9. Shell Programming and Scripting
Hi,
I'm using the command: sed -n '$=' $1 on a sh script on AIX.
This script is used to count the number of lines of files.
If the file has no lines at all the command doesn't return nothing.
I need the command to return 0 when the file has no lines at all.
How can I achieve this?
Best... (5 Replies)
Discussion started by: jppedroso
5 Replies
10. UNIX for Dummies Questions & Answers
Counting number of lines: sp
I am trying to figure out a script to count the number of text files in cywig and have it give me a number (as the answer) any help would be appreciated.
I am new here, so be gentle :D (3 Replies)
Discussion started by: unicksjp
3 Replies
fold(1) User Commands fold(1)
NAME
fold - filter for folding lines
SYNOPSIS
fold [-bs] [-w width | -width] [file...]
DESCRIPTION
The fold utility is a filter that will fold lines from its input files, breaking the lines to have a maximum of width column positions (or
bytes, if the -b option is specified). Lines will be broken by the insertion of a NEWLINE character such that each output line (referred to
later in this section as a segment) is the maximum width possible that does not exceed the specified number of column positions (or bytes).
A line will not be broken in the middle of a character. The behavior is undefined if width is less than the number of columns any single
character in the input would occupy.
If the CARRIAGE-RETURN, BACKSPACE, or TAB characters are encountered in the input, and the -b option is not specified, they will be treated
specially:
BACKSPACE The current count of line width will be decremented by one, although the count never will become negative. fold
will not insert a NEWLINE character immediately before or after any BACKSPACE character.
CARRIAGE-RETURN The current count of line width will be set to 0. fold will not insert a NEWLINE character immediately before or
after any CARRIAGE-RETURN character.
TAB Each TAB character encountered will advance the column position pointer to the next tab stop. Tab stops will be at
each column position n such that n modulo 8 equals 1.
OPTIONS
The following options are supported:
-b Counts width in bytes rather than column positions.
-s If a segment of a line contains a blank character within the first width column positions (or bytes), breaks the line after
the last such blank character meeting the width constraints. If there is no blank character meeting the requirements, the
-s option will have no effect for that output segment of the input line.
-w width|-width Specifies the maximum line length, in column positions (or bytes if -b is specified). If width is not a positive decimal
number, an error is returned. The default value is 80.
OPERANDS
The following operand is supported:
file A path name of a text file to be folded. If no file operands are specified, the standard input will be used.
EXAMPLES
Example 1: Submitting a file of possibly long lines to the line printer
An example invocation that submits a file of possibly long lines to the line printer (under the assumption that the user knows the line
width of the printer to be assigned by lp(1)):
example% fold -w 132 bigfile | lp
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of fold: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 All input files were processed successfully.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
cut(1), pr(1), attributes(5), environ(5), standards(5)
NOTES
fold and cut(1) can be used to create text files out of files with arbitrary line lengths. fold should be used when the contents of long
lines need to be kept contiguous. cut should be used when the number of lines (or records) needs to remain constant.
fold is frequently used to send text files to line printers that truncate, rather than fold, lines wider than the printer is able to print
(usually 80 or 132 column positions).
fold may not work correctly if underlining is present.
SunOS 5.10 1 Feb 1995 fold(1)