06-03-2008
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 do it at end of each line?
Thanks
10 More Discussions You Might Find Interesting
1. 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
2. Shell Programming and Scripting
Hi,
Does anyone know if its possible to add something like an end of line like c or java in unix?
dirs=/home/nosnam
var=''
for dir in $dirs
do
listDirs=`ls -d1 $dir/*`
for eachList in $listDirs
do
listRepos=`du -ks $eachList | awk '{ x+=$1 }; END { print x... (4 Replies)
Discussion started by: nosnam
4 Replies
3. Solaris
Hello All,
Currently I am attempting to write a script which will capture a number at the end of a line.
The line which I am searching through ends as follows:
word word=number
for example
word word=3
OR
word word=15
I am stuck on how to capture whatever is to the right... (3 Replies)
Discussion started by: icalderus
3 Replies
4. Shell Programming and Scripting
hi,
i have file which is having large sql query
eg :
i am executing this sql file but now i want to add ; after query on same line
i.e. i should look like
any idea how to achieve it ? (6 Replies)
Discussion started by: crackthehit007
6 Replies
5. Shell Programming and Scripting
I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed).
AU * A01 EXPENSE 6990370000 CWF SUBC TRAVEL & MISC
MY * A02 RESALE 6990788000 Y... (3 Replies)
Discussion started by: udelalv
3 Replies
6. Shell Programming and Scripting
Hi All,
I have a file which has some Linux commands in every line like
more 456.dat
more 3232.dat
more 433.dat
I want to add texts like this at the end of every line:
more 456.dat > 1.txt
more 3232.dat > 2.txt
more 433.dat > 3.txt
So, that the result of more goes into 1.txt... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies
7. UNIX for Dummies Questions & Answers
I'm trying to grep lines where the digits at the end of each line are greater than digits. Tried this but it will only allow me to specify 2 digits. Any ideas would greatly be appreciated. grep -i '\<\{3,4,5\}\>' file
---------- Post updated at 05:58 PM ---------- Previous update was at 05:41... (1 Reply)
Discussion started by: jimmyf
1 Replies
8. Shell Programming and Scripting
How to add a comma at the end of each line in this file?30 1412
30 3352
30 5254
30 5543
30 7478
3 28
3 30
3 39
3 54
3 108
3 152
3 178
3 182
3 214
3 271
3 286
3 300
3 348
3 349
3 371 (3 Replies)
Discussion started by: gunjan
3 Replies
9. Shell Programming and Scripting
Hai,
I have got a small requirement in my script. and i am using bash shell. I need to add a dot (.) for some particular line in a file. Say for example,
$Cat rmfile
1 This is line1
2 This is line2
3 This is line3
O/p should be :
$Cat rmfile
1 This is line1
2 This is line2. #... (2 Replies)
Discussion started by: Sivajee
2 Replies
10. Red Hat
Hi,
I have a file which is an extract of jil codes of all autosys jobs in our server.
Sample jil code:
**************************
permission:gx,wx
date_conditions:yes
days_of_week:all
start_times:"05:00"
condition: notrunning(appDev#box#ProductLoad)... (1 Reply)
Discussion started by: raghavendra
1 Replies