03-16-2011
How to get evenly Line numbers?
hi there ,
i m new to unix , i d like to ask how can a get only even numbered lines matches with the word i search from txt file
for example :
3461:1.D. The copyright laws of the place where you are located also govern
3471:1.E. Unless you have removed all references to Project Gutenberg:
3473:1.E.1. The following sentence, with active links to, or other immediate
3485:1.E.2. If an individual Project Gutenberg-tm electronic work is derived
3494:1.E.9.
3496:1.E.3. If an individual Project Gutenberg-tm electronic work is posted
3503:1.E.4. Do not unlink or detach or remove the full Project Gutenberg-tm
3507:1.E.5. Do not copy, display, perform, distribute or redistribute this
3513:1.E.6. You may convert to and distribute this work in any binary,
3525:1.E.7. Do not charge a fee for access to, viewing, displaying,
3529:1.E.8. You may charge a reasonable fee for copies of or providing
3562:1.E.9. If you wish to charge a fee or distribute a Project Gutenberg-tm
3569:1.F.
3571:1.F.1. Project Gutenberg volunteers and employees expend considerable
i want to grep (or any other commands ) the evenly number lines such as ;
.
.
.
3496:1.E.3. If an individual Project Gutenberg-tm electronic work is posted
3494:1.E.9.
3562:1.E.9. If you wish to charge a fee or distribute a Project Gutenberg-tm
.
.
.
i hope i m clear enough i tried many regular expressions but didn t work
THE PROBLEM IS PUNCTUATION ( : ) i believe bcus it reads them all as one string that makes it hard to seperate! , there might be other numbers in the line !
i don t know why this doesn t work grep -n '[0-9]*[08]*' list.txt
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Maybe this question is out there, but I searched and didnt see it.
To print my files I use
more filename | lpr -Pprinter
I would like to print my scripts with line numbers.
How do I do this? (2 Replies)
Discussion started by: MizzGail
2 Replies
2. Shell Programming and Scripting
Hello..
I have got one file ...
I want to add line numbers with space form starting to ending..
for example...if the file is
--------------------------
sand sorcd 2345 345
recds 234 234 5687
yeres 568 988 erfg4 67
--------------------------
I need the output
... (4 Replies)
Discussion started by: esham
4 Replies
3. UNIX for Advanced & Expert Users
Hi i would like to add line numbers to end of each line in a file.
I am able to do it in the front of each line using sed, but not able to add at the end of the file.
Can anyone suggest
The following code adds line number to start of each line
sed = filename | sed 'N;s/\n/\t/'
how can i... (5 Replies)
Discussion started by: rudoraj
5 Replies
4. Shell Programming and Scripting
Hi all experts,
I am getting error in my shell scripts and i want to find out which lines is in errors. How i can display the line numbers . Is it NU command? Please give me some suggestions. (4 Replies)
Discussion started by: ma466
4 Replies
5. Shell Programming and Scripting
Hi all,
I have a file consisting of lines in such a format: separated by space and M1 EOS for fullstop (.) ]
e.g
M1 I
M1 have
M1 a
M1 file
M1 consisting
M1 of
M1 lines
M1 in
M1 such
M1 a
M1 format
M1 EOS
M2 This
M2 is
M3 an (4 Replies)
Discussion started by: my_Perl
4 Replies
6. Shell Programming and Scripting
Hi All,
How to get line numbers when we more on a file in LINUX
thanks
firestar (1 Reply)
Discussion started by: firestar
1 Replies
7. UNIX for Dummies Questions & Answers
I know if i use grep -n that the output will have the lines numbered but is there a way to grep the actually line number.
so like this
grep -n "one" /usr/dict/numbers
1:one
21:twenty-one
31:thirty-one
41:forty-one
51:fifty-one
61:sixty-one
71:seventy-one
81:eighty-one
91:ninety-one
... (1 Reply)
Discussion started by: alindner
1 Replies
8. Shell Programming and Scripting
Hi! I'm trying to assign line numbers to each line of the file
for example consider the following..
The contents of the input file are
hello how are you?
I'm fine.
How about you?
I'm trying to get the following output..
1 hello how are you?
2 I'm fine.
3 How about you? ... (8 Replies)
Discussion started by: abk07
8 Replies
9. Shell Programming and Scripting
hi,
I need some unix command to replace the following thing. The line shuld start with oly numbers. If it starts with anything other than number it shuld be taken back to the last line.
My file:
1234|test
weye|test1|break
576|test|break|title
2369|test|line|break
tite|break... (7 Replies)
Discussion started by: anshaa
7 Replies
10. UNIX for Dummies Questions & Answers
Hello All,
I am very sure this a dumb question to many, but from my view its worth asking.
When I do a vi on a file, on the right bottom side I am seeing something like below:
27,16-24 7%
which tells me that I am on line 27 (which is the first number before the comma, i would like... (11 Replies)
Discussion started by: babyPen1985
11 Replies
LEARN ABOUT DEBIAN
perl::critic::policy::valuesandexpressions::prohibitimplicitnewl
Perl::Critic::Policy::ValuesAndExpressions::ProhibitImplUserNContributed)Perl::Critic::Policy::ValuesAndExpressions::ProhibitImplicitNewlines(3pm)
NAME
Perl::Critic::Policy::ValuesAndExpressions::ProhibitImplicitNewlines - Use concatenation or HEREDOCs instead of literal line breaks in
strings.
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
Strings with embedded line breaks are hard to read. Use concatenation or HEREDOCs instead.
my $foo = "Line one is quite long
Line two"; # Bad
my $foo = "Line one is quite long
Line two"; # Better, but still hard to read
my $foo = "Line one is quite long
"
. "Line two"; # Better still
my $foo = <<'EOF'; # Use heredoc for longer passages
Line one is quite long
Line two
Line three breaks the camel's back
EOF
CONFIGURATION
This Policy is not configurable except for the standard options.
AUTHOR
Chris Dolan <cdolan@cpan.org>
CREDITS
Initial development of this policy was supported by a grant from the Perl Foundation.
COPYRIGHT
Copyright (c) 2007-2011 Chris Dolan. Many rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
perl v5.14.2 2012-Perl::Critic::Policy::ValuesAndExpressions::ProhibitImplicitNewlines(3pm)