Adding the squence numbers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding the squence numbers
# 1  
Old 10-06-2017
Adding the squence numbers

Hi All,

Could you please help me on this requirement.

File data:
Code:
A
A
A
B
B
B

i need the output like

Code:
A1
A2
A3
B1
B2
B3

Thanks,
Mk
# 2  
Old 10-06-2017
Welcome to the forum.

Any attempts / ideas / thoughts from your side? Any preferred tools? And - please indicate if this is homework / classwork or not.
# 3  
Old 10-06-2017
Hello bmk123,

Welcome to UNIX and Linux forums. Could you please try following and let me know if this helps you.
Code:
awk '{print $0,++a[$0]}' OFS=""  Input_file

Thanks,
R. Singh
These 2 Users Gave Thanks to RavinderSingh13 For This Post:
# 4  
Old 10-08-2017
Thanks alot Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Squence number manipulation in Shell

Hello Forum, I am receiving a file daily like ASAD but at the end there is a counter like 0012 (4 digits) so my every next file +1 I want to write a control script and check the last sequence number.Let's say If I receive a file ASAD0012 then after receiving this file I wan to say that... (5 Replies)
Discussion started by: cemokam65
5 Replies

2. Shell Programming and Scripting

Adding (as in arithmetic) to numbers in columns in file, and writing new file with new numbers

Hi again. Sorry for all the questions — I've tried to do all this myself but I'm just not good enough yet, and the help I've received so far from bartus11 has been absolutely invaluable. Hopefully this will be the last bit of file manipulation I need to do. I have a file which is formatted as... (4 Replies)
Discussion started by: crunchgargoyle
4 Replies

3. UNIX for Dummies Questions & Answers

Adding Column Of Numbers

Hello. Trying to add a column of numbers and combine the 1st and 2nd fields as uniq with the new total. This works to add the numbers but can't figure an easy was to combine the 1st and 2nd column as the list is very long. awk '{s+=$3} END {print s}' bird dog 300 bird dog 100 cat clown 200... (1 Reply)
Discussion started by: jimmyf
1 Replies

4. Shell Programming and Scripting

help with adding up numbers

I have a file which has following contents which I want to add up. 28170.24 28170.24 28170.24 28170.24 28170.24 28170.24 28170.24 28170.24 28170.24 28170.24 28170.24 28170.24 28170.24 28170.24 139038.72 139038.72 139038.72 139038.72 (5 Replies)
Discussion started by: aksijain
5 Replies

5. Shell Programming and Scripting

Adding row of numbers

is there another way of doing the below: echo "7 3 8 2 2 1 3 83.4 8.2 4 8 73 90.5" | bc shell is bash. os is linux and sunos. bc seems to have an issue with long range of numbers (12 Replies)
Discussion started by: SkySmart
12 Replies

6. Shell Programming and Scripting

Adding numbers

Hi I figured how to add my list of numbers. However how do I count so that after a certain number it lists the line. Example: 12 test1 46 test2 195 test3 174 test4 634 test5 185 test6 94 test7 So basically add the numbers and when the addition reaches 300 or less print the... (8 Replies)
Discussion started by: bombcan
8 Replies

7. UNIX for Dummies Questions & Answers

adding hundreds of numbers

i know how to add two numbers using expr, but if i have a file with hundreds of numbers, how do i add them all together, without typing them all one by one? for example, file.txt contains 4 5 6 7 how can i give a command to add them, without typing $ expr `4 + 5 + 6 + 7` (7 Replies)
Discussion started by: FOBoy
7 Replies

8. UNIX for Advanced & Expert Users

Adding a column of numbers

Hello, I have a file, and one column has both positive and negative numbers. Does anyone know how I can calculate the total of all the values (i.e, +ve and -ve). eg: col1 col2 col3 data 23 data data 76 data data -30 data Thanks Khoom (1 Reply)
Discussion started by: Khoomfire
1 Replies

9. Shell Programming and Scripting

adding float numbers

how to add 2 float values to each other? i tried this and it doesnt work: #!bin/bash numone=1.234 numtwo=0.124 total=`expr $numone + $numtwo` echo $total thanks (5 Replies)
Discussion started by: strike
5 Replies

10. Shell Programming and Scripting

Adding 2 numbers

I would like to write a script with BASH to add two numbers (integer) and write the result to the standard output. Please help! (7 Replies)
Discussion started by: Viper01
7 Replies
Login or Register to Ask a Question