i have this text file name test.txt which contain :
aaaaa bbb
iiiiiiiiiiiii ccf
ddaaa ddd
and i need a script that can print out the line numbers using a while loop..
so when the script is run..it will have this:
1
2
3
any ideas? :) thanks guys (4 Replies)
Hi
Is there any command to scan thru a file looking for 2 consecutive blank lines and if any remove one of them. Please let me know.
Regards,
Tipsy (6 Replies)
All I want is to look for the pattern in the file...If I found it at # places... I want print lines after those pattern(line) until I find a blank line.
Log EXAMPLE :
MT:Exception caught
The following Numbers were affected:
1234
2345
2346
Error
java.lang.InternalError:... (3 Replies)
I am parsing a nagios config, searching for a string, and then printing the line 2 lines later (the "members" string). Here's the data:
define hostgroup{
hostgroup_name chat-dev
alias chat-dev
members thisisahostname
}
define hostgroup{
... (1 Reply)
Hi,
I have a file, say files_list, as below (o/p of ls -R cmd)
$ cat files_list
/remote/dir/path/to/file:
sub-dir1
sub-dir2
sub-dir3
...
/remote/dir/path/to/file/sub-dir1:
remote_file1.csv.tgz
<blank line 1>
/remote/dir/path/to/file/sub-dir2:
remote_file2.csv.tgz
<blank... (3 Replies)
Hello,
I have a file that I want to be able to insert a new line before every instance of a regex. I can get it to do this for each line that contains the regex, but not for each instance.
Contents of infile:
Test this 1...
Test this 2...
Test this 3... Test this 4... Test this... (2 Replies)
Hi Team,
The content of the file is as follows.
asdf
234
asdf
asdf
dsfg
gh
67
78
The file is in DOS format (not in Unix Format). The file is transferred to Unix. I need a unix command to check the number of blank lines in a input (comming from Windows). If it is greater than... (4 Replies)
Hi All,
This might be a basic question... I need to write a script to find all/any Speacial/Null/Control Chars and Print Line Numbers from an input file.
Output something like
Null Characters in File Name at : Line Numbers
Line = Print the line
Control Characters in File Name at : Line... (2 Replies)
Dear all
I want to search special string in file and then print next all line in one line until blank lines come. Help me plz for same. My input file and desire op file is as under.
i/p file:
A1/EXT "BSCABD1_21233G1" 757 130823 1157
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT
... (7 Replies)
Hi ,
i have a file with data as below.This is same file. But actual file contains to many rows.
i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ?
Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies
LEARN ABOUT ULTRIX
nl
nl(1) General Commands Manual nl(1)Name
nl - line numbering filter
Syntax
nl [-h type] [-b type] [-f type] [-v start#] [-i incr] [-p ] [-l num] [-s sep] [-w width] [-n format] [-d delim] file
Description
The command reads lines from the named file or from the standard input, if no file is named, and reproduces the lines on the standard out-
put. Lines are numbered on the left in accordance with the command options in effect.
The command views the text it reads in terms of logical pages. Line numbering is reset at the start of each logical page. A logical page
consists of a header, a body, and a footer section. Empty sections are valid. Different line numbering options are independently avail-
able for header, body, and footer. For example, you can elect not to number header and footer lines while numbering blank lines in the
body.
The start of logical page sections is signaled by input lines containing nothing but the following delimiter characters:
Line contents Start of
::: header
:: body
: footer
Unless otherwise specified, assumes that the text it is reading is in the body of a single logical page.
Options
Command options may appear in any order and may be intermingled with an optional file name. Only one file may be named.
-b type Specifies which logical page body lines are to be numbered. The following are recognized types and their meaning: a,
number all lines; t, number lines with printable text only; n, no line numbering; pstring, number only lines that con-
tain the regular expression specified in string.
The default type for logical page body is t (text lines numbered).
-h type Same as -b type except for header. Default type for logical page header is n (no lines numbered).
-f type Same as -b type except for footer. Default for logical page footer is n (no lines numbered).
-p Do not restart numbering at logical page delimiters.
-v start# The initial value used to number logical page lines. Default is 1.
-i incr The increment value used to number logical page lines. Default is 1.
-s sep The character used in separating the line number and the corresponding text line. Default sep is a tab.
-w width The number of characters used for the line number. Default width is 6.
-n format The line numbering format. Recognized values are the following: ln, left justified, leading zeroes suppressed; rn,
right justified, leading zeroes suppressed; rz, right justified, leading zeroes kept. Default format is rn (right jus-
tified).
-l num The number of blank lines to be considered as one. For example, -l2 results in only the second adjacent blank being
numbered (if the appropriate -ha, -ba, or -fa option is set). Default is 1.
-d xx The delimiter characters specifying the start of a logical page section may be changed from the default characters (:)
to two user-specified characters. If only one character is entered, the second character remains the default character
(:). No space should appear between the -d and the delimiter characters. To enter a backslash, you must type two
backslashes (//).
Examples
nl -v10 -i10 -d!+ file1
This command numbers file1 starting at line number 10 with an increment of ten. The logical page delimiters are !+.
See Alsopr(1)nl(1)