how to number format a data file without using SED?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to number format a data file without using SED?
# 1  
Old 01-12-2008
how to number format a data file without using SED?

Hi I have a file which contains data (list of data) and I want to put a number with bracket 1) 2) 3) etc at the beginning of every successive line

I can do it with SED and I can also do it using the nl route but am looking for a different method.

I'm guessing I would need some sort of loop for each line. Can someone please give me some pointers.

Thanks

Last edited by Cactus Jack; 01-12-2008 at 07:30 PM..
# 2  
Old 01-12-2008
One way...
awk '{ print NR ")", $0}'
# 3  
Old 01-12-2008
Hi Perderabo, I can't use Awk or Sed (thats for later on in my course). I have found a solution using nl but I want do take the long route on this one and use the shell programming techniques I have learned so far. Any ideas?
# 4  
Old 01-12-2008
Quote:
Originally Posted by Cactus Jack
Hi Perderabo, I can't use Awk or Sed (thats for later on in my course). I have found a solution using nl but I want do take the long route on this one and use the shell programming techniques I have learned so far. Any ideas?
Yeah, read the rules


(6) Do not post classroom or homework problems.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed/awk command to convert number occurances into date format and club a set of lines

Hi, I have been stuck in this requirement where my file contains the below format. 20150812170500846959990854-25383-8.0.0 "ABC Report" hp96880 "4952" 20150812170501846959990854-25383-8.0.0 End of run 20150812060132846959990854-20495-8.0.0 "XYZ Report" vg76452 "1006962188"... (6 Replies)
Discussion started by: Chinmaya Kabi
6 Replies

2. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

3. UNIX for Advanced & Expert Users

Identifing The Format of Data File

Hello All, We are receiving UTF-16 formatted file and when i vi the file in Linux OS i am seeing some weird characters, is this because in my .bashrc profile the language variable has been set to LC_ALL=en_US.UTF-8 and hence the reason i am not able to read the UTF-16 formatted file properly? or... (2 Replies)
Discussion started by: Ariean
2 Replies

4. UNIX for Dummies Questions & Answers

Format the data file

hi all, i am new to unix forum,i want do some large data format work. pls help me to format the file. i have attched data file to be formated in that two set of line item is there . first set header & second set header to be come in to single header item same as like all the data also. ... (2 Replies)
Discussion started by: dhamu
2 Replies

5. UNIX for Dummies Questions & Answers

How to Open a data format file?

Hi, Am having a file. I checked that file format by the following command file filename Output is filename: data So the file is data format file Am trying to view that file so i have used some commands like cat,more so on but it showing the contents like compressed form(full of Symbols). How... (4 Replies)
Discussion started by: Adhi
4 Replies

6. Shell Programming and Scripting

Masking data for different file format

Hi, I have 3 kind of files that contains date data needed to be masked. The file is like this: File 1 (all contents in 1 line): input:DTM+7:201103281411:203'LOC+175+SGSIN:139:6+TERMINATOR......'DTM+132:201103281413:203'LOC.... output:... (4 Replies)
Discussion started by: Alvin123
4 Replies

7. UNIX for Dummies Questions & Answers

Format/Fix Timestamp Data in a File.

Hello Experts, I have a timestamp(6) column in a .csv data file , format of the data is as below:- ETCT,P,Elec, Inc.,abc,11/5/2010 4:16:09.000000 PM,Y,Y,Y I want the timestamp column to be properly formatted like 11/05/2010 04:16:09.000000 PM Currently the "0" is missing with... (3 Replies)
Discussion started by: mtlrsk
3 Replies

8. OS X (Apple)

get file modification date in number format (yyyy mm dd hh mm ss)

How do i get the file modification date in number format (yyyy mm dd hh mm ss) i used ls -l pathname but month is still in text "Aug" and year and time is not allways shown. time is show if it is in this year. and year is shown if it is before this year. what do i need to get... (7 Replies)
Discussion started by: rvdokkum
7 Replies

9. UNIX for Advanced & Expert Users

Sed to format data in a file

Hi , i need help with formatting a file i am generating which is to be used in mainframe app so the file length has to be 80 for each rows. The file that m able to generate looks like this (consists of two rows only) E 1006756 1006756 Active T E 0551055 0551055 Active T I... (2 Replies)
Discussion started by: cnilashis
2 Replies

10. Shell Programming and Scripting

Help with format a number in a file

Hey, I have a file which starts each line with 6 digits followed bya colon: 090607:The rest of the line 091207:Also some text 091207:Here's some more text And I want to reformat them into: 06-09-07:The rest of the line 12-09-07:Also some text 12-09-07:Here's some more text I... (3 Replies)
Discussion started by: kabatsie
3 Replies
Login or Register to Ask a Question