01-24-2014
Quote:
Posted by Yoda:
Also if required, add -n option to format (ln - left justified, leading zeroes suppressed):
Code:
nl -v0 -i5 -nln file
Hello Yoda,
Could you please explain the code.
Thanks,
R. Singh
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to add a line of text just before the last line in a file.
For example, if the last line of a file is "exit 0", I need to add a line of text just before that.
Any ideas how I might do that?
Thanks (5 Replies)
Discussion started by: TheCrunge
5 Replies
2. Shell Programming and Scripting
Hi I need to add a comment line at the begining of a text file. The scenario is given below.
1. The number of servers that needs to be updated is around 80
2. The location of the text file in all the servers are the same including the file name.
3. The comment has to be added at the very... (2 Replies)
Discussion started by: orakhan
2 Replies
3. Shell Programming and Scripting
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)
Discussion started by: forevercalz
4 Replies
4. Shell Programming and Scripting
hi, i have a large text file that I just want to extract the important
information from. It will be a random number of lines but between two specific
line numbers/markers.
I was thinking I could get the line number for the first marker:
Tablespace Percent Total Free
Then get the line... (11 Replies)
Discussion started by: Da_Duck
11 Replies
5. Shell Programming and Scripting
Hi all
How to add line numbers in text file..
ex
abcd
cdef
result
1. abcd
2. cdef
thx in advance (4 Replies)
Discussion started by: suryanarayana
4 Replies
6. Shell Programming and Scripting
hello,
how can I add one text line string at the line number one of a file.
thankx, (5 Replies)
Discussion started by: Ahmed waheed
5 Replies
7. Shell Programming and Scripting
Please help to add ; to every line in a text file
i Have tired sed 's/$/ ; /g' > /tmp/drop_tables.sql but not working :(
Thanks (2 Replies)
Discussion started by: bluebird5m
2 Replies
8. Shell Programming and Scripting
I've been playing with sed, trying to get it to insert the contents of somefile.txt after line 13 on anotherfile.txt. I tried searching for a line with regex and attempting to insert something on the next line with:
find ./anotherfile.txt -type f -exec sed -i -e '/^dog/cat/' {} \;
but it... (2 Replies)
Discussion started by: unclecameron
2 Replies
9. Shell Programming and Scripting
I need help with insert text to the last line of text file with echo command
I know can do something like echo "i4\n$logtext\n.\nwq" | ex -s $file can insert to first line, but how can i change this code in order to insert to the last line of text file?
please help, thank you :( (2 Replies)
Discussion started by: gavin_L
2 Replies
10. UNIX for Dummies Questions & Answers
Hi,
I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies
NL(1) User Commands NL(1)
NAME
nl - number lines of files
SYNOPSIS
nl [OPTION]... [FILE]...
DESCRIPTION
Write each FILE to standard output, with line numbers added. With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-b, --body-numbering=STYLE
use STYLE for numbering body lines
-d, --section-delimiter=CC
use CC for separating logical pages
-f, --footer-numbering=STYLE
use STYLE for numbering footer lines
-h, --header-numbering=STYLE
use STYLE for numbering header lines
-i, --line-increment=NUMBER
line number increment at each line
-l, --join-blank-lines=NUMBER
group of NUMBER empty lines counted as one
-n, --number-format=FORMAT
insert line numbers according to FORMAT
-p, --no-renumber
do not reset line numbers at logical pages
-s, --number-separator=STRING
add STRING after (possible) line number
-v, --starting-line-number=NUMBER
first line number on each logical page
-w, --number-width=NUMBER
use NUMBER columns for line numbers
--help display this help and exit
--version
output version information and exit
By default, selects -v1 -i1 -l1 -sTAB -w6 -nrn -hn -bt -fn. CC are two delimiter characters for separating logical pages, a missing second
character implies :. Type \ for . STYLE is one of:
a number all lines
t number only nonempty lines
n number no lines
pBRE number only lines that contain a match for the basic regular expression, BRE
FORMAT is one of:
ln left justified, no leading zeros
rn right justified, no leading zeros
rz right justified, leading zeros
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report nl translation bugs to <http://translationproject.org/team/>
AUTHOR
Written by Scott Bartram and David MacKenzie.
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 nl is maintained as a Texinfo manual. If the info and nl programs are properly installed at your site, the com-
mand
info coreutils 'nl invocation'
should give you access to the complete manual.
GNU coreutils 8.22 June 2014 NL(1)