Display Line numbers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Display Line numbers
# 1  
Old 01-05-2009
Display Line numbers

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.

Last edited by joeyg; 01-05-2009 at 12:28 PM.. Reason: Corrected spelling
# 2  
Old 01-05-2009
Code:
sed = filename | sed 'N;s/\n/\t/'

or

sed = filename | sed 'N; s/^/     /; s/ *\(.\{6,\}\)\n/\1  /'


Last edited by Ikon; 01-05-2009 at 11:22 AM..
# 3  
Old 01-05-2009
Thanks.
# 4  
Old 01-06-2009
Code:
cat -n filename

# 5  
Old 01-06-2009
I am not sure which shell you are using, I am assuming it is bash shell.

You can try the following to debug your script:

Code:
bash -v myscript

or :

Code:
bash -x myscript

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

VI editior line numbers

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

2. UNIX for Dummies Questions & Answers

To find and display the middle line in a file using single line command.

Hi all, How can i display the middle line of a file using a single line command? (6 Replies)
Discussion started by: Lakme Pemmaiah
6 Replies

3. Shell Programming and Scripting

using sed command to display contents where line numbers are stored in variables

if i want to display the contents of a file between say line number 3 and 10 then i use the following command sed -n '3,10p' filename if this 3 was contained in x and 10 was contained in y then how wud this command modified? sed -n '$x,$yp' filename does not work..please advise (2 Replies)
Discussion started by: arindamlive
2 Replies

4. Shell Programming and Scripting

Assign Line Numbers to each line of the file

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

5. UNIX for Dummies Questions & Answers

grep to get line numbers

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

6. Shell Programming and Scripting

More with line numbers

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. Shell Programming and Scripting

Removing Line numbers

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

8. Shell Programming and Scripting

Display mutiple line in single line

Hi All, I had a file called Input.txt, i need to group up in a single line as 1=ttt and the no of lines may vary bewteen the 1=ttt cat Input.txt 1=ttt,2=xxxxxx, 3=4545 44545, 4=66667 7777, 5=77723 1=ttt, 2=xxxxxx, 3=34436 66 3545, 4=66666, 5=ffffff, 6=uuuuuuu 1=ttt, 2=xxxxxx,... (4 Replies)
Discussion started by: manosubsulo
4 Replies

9. Shell Programming and Scripting

display lines b/w given line numbers

write a shell script that accepts a file name starting and ending line numbers as arguments and displays all the lines between the given line numbers:b:.help is appreciated.thank you. (3 Replies)
Discussion started by: shawz
3 Replies

10. UNIX for Advanced & Expert Users

Add line numbers to end of each line

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
Login or Register to Ask a Question