The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
generating line numbers sam4now Shell Programming and Scripting 7 04-28-2008 06:17 PM
Need help capturing end of line numbers icalderus SUN Solaris 3 09-21-2007 02:34 AM
Searching for data on a specific line numbers rkumar28 Shell Programming and Scripting 8 06-18-2005 12:34 AM
Printing line numbers MizzGail UNIX for Dummies Questions & Answers 2 07-25-2002 04:18 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-06-2005
esham's Avatar
esham esham is offline
Registered User
  
 

Join Date: Nov 2004
Location: INDIA
Posts: 107
add line numbers

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

----------------------------
1 sand sorcd 2345 345
2 recds 234 234 5687
3 yeres 568 988 erfg4 67
------------------------------

please help..
thanks in advance
esham
  #2 (permalink)  
Old 03-06-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Try:
nl -s " " -b a /path/to/text.file
  #3 (permalink)  
Old 03-06-2005
esham's Avatar
esham esham is offline
Registered User
  
 

Join Date: Nov 2004
Location: INDIA
Posts: 107
thanks...
that worked..... kisses


esham
  #4 (permalink)  
Old 03-07-2005
muthukumar muthukumar is offline
Registered User
  
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
You got the answer. More way to do this as,
Code:
awk '{ print NR" "$0 }' <filename>
sed = <filename> | sed 'N;s/\n/ /'
HTH.
  #5 (permalink)  
Old 03-07-2005
ZealeS ZealeS is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 29
cat -b filename
cat -n filename
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0