Need to put semicolon


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to put semicolon
# 1  
Old 03-22-2012
Need to put semicolon

Hi guys,

I want to write script so that i can put semicolon after every numeric


e.g
input would be like that
50060E80058F49A4


Output should be

50:06:0E:80:05:8F:49:A4

Please help

Thanks & Regards
Nirjhar
# 2  
Old 03-22-2012
Code:
#! /bin/bash
while read x
do
    y=''
    while [ ${#x} -gt 0 ]
    do
        y="${y}${x:0:2}:"; x=${x#??}
    done
    echo ${y%?}
done < inputfile

or

Code:
sed 's/\(..\)/\1:/g; s/:$//' inputfile

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 03-22-2012
Thanks for the reply it is properly working with the While loop...
but i want to do it with the sed and it is not giveing the right output...

I have little bit idea of sed,it would be great if u can explain the little......so i can modify the same acording to my need..

Thanks
Nirjhar
# 4  
Old 03-22-2012
or try like this
Code:
# sed 's/../&:/g;s/.$//'

# 5  
Old 03-22-2012
Thanks for the reply again but i am getting the minor mistake....

5:00:60:E8:00:58:F4:90: it is coming like that......Smilie

# 6  
Old 03-22-2012
Quote:
Originally Posted by nirjhar17
Thanks for the reply again but i am getting the minor mistake....

5:00:60:E8:00:58:F4:90: it is coming like that......Smilie

what is your code and inputfile?
# 7  
Old 03-22-2012
The input file is

50060E80058F4900
50060E80058F4920
50060E80058F4901
50060E80058F4921
50060E80058F4904
50060E80058F4924
50060E80058F4905
50060E80058F4925
50060E80058F4984
50060E80058F49A4
50060E80058F4985
50060E80058F49A5
50060E80058F4910
50060E80058F4930
50060E80058F4911
50060E80058F4931
50060E80058F4914
50060E80058F4934
50060E80058F4915
50060E80058F4935
50060E80058F4994
50060E80058F49B4
50060E80058F4995
50060E80058F49B5
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace semicolon within double quotes in a file with semicolon delimiter

Hello Team, Could you please help me with the below question? I have a file with the following properties 1) File Delimiter is ; 2) Text columns are within double quotes 3) Numeric columns will not have double quotes 4) File has total 6 columns Please see a sample record from file ... (3 Replies)
Discussion started by: sam99
3 Replies

2. Shell Programming and Scripting

How to use substr to extract character between two semicolon?

Dear folks Hello I have a data set which one of the column of this data set are string and I want to extract numbers which is between two ":". However, I know the substr command which will do this operation but my problem is the numbers between two ":" have different digits. this will make my... (11 Replies)
Discussion started by: sajmar
11 Replies

3. Shell Programming and Scripting

How to have semicolon at the end of every line?

Hi, I wanted to create an automated script that will output a create table statement in unix. Below is the input and the desired output: INPUT: desc ZZ_APL_TIDDATELIST ( TID NUMBER AEX_DATE TIMESTAMP(6) ) desc ZZ_APL_TIDLIST ( TID NUMBER ) desc... (5 Replies)
Discussion started by: reignangel2003
5 Replies

4. Shell Programming and Scripting

Inserting semicolon at the end of a line

HI Am totally confused with sed and translate command command.. My problem is I have a file like # vi test.csv ABC_IMUY ERD0_FN VEG_NON_DES_IYT BUY4_FLOW POI_SHD_URDF_IYUT_REDS_CYC UYT_PMC4_WIND EX_FRE_FRD_L2_REF_FLICT JHY_SGT_DSE_L2 IYO_HYTR_FGT_L3_BGT_ICT... (5 Replies)
Discussion started by: Priya Amaresh
5 Replies

5. UNIX for Dummies Questions & Answers

Delete a semicolon and numbers after a semicolon

I have this: ((9:0.010,(11:0.089,13:0.004)) and I would like this: ((A9,(A11,A13)) How do I delete the semi colon and the number (i.e. 0.010) after the semi colon? Also, how can I add the letter before the number that is NOT removed? Thank you in advance! ---------- Post updated... (4 Replies)
Discussion started by: MDeBiasse
4 Replies

6. Shell Programming and Scripting

Adding semicolon at the end of each line

Hi, I have a script which I need to change. I want to add a semicolon at the end of each line where the line starts with "grant" for e.g. create table(.... ); grant select on TABL1 to USER1 grant select on TABL1 to USER2should become create table(.... ); grant select on TABL1 to... (3 Replies)
Discussion started by: pparthiv
3 Replies

7. Shell Programming and Scripting

Delete lines after semicolon

char str; char str ; char *ptr; char * ptr; int CASE; int CASE; double temp; double temp; Output should be: char str; char *ptr; int CASE; double temp; How can i do this with awk,sed,perl? (5 Replies)
Discussion started by: cola
5 Replies

8. Shell Programming and Scripting

Replace a string after n semicolon every line

I have a file that is formatted in this way. a1;b2;c33;d4;e5;e;f;f;f;s d;ds;d;a;v;b;g;gr;r;rt;fdf s1;s2;s2;s3;s4; b1;f2;g3;h4;a3c4e;xcsd;fds; sd2;fs4;fs2;sdf3; I want to replace the value just before the 4th semicolon to empty string, regardless the value, such that it looks... (3 Replies)
Discussion started by: alienated
3 Replies

9. UNIX for Dummies Questions & Answers

wget with semicolon in page name

So, I'd like to wget a webpage, as its not going to stick around forever - but the problem is the webpage has a semicolon in it. wget http://example.com/stuff/asdf;asdf obviously doesn't get the right webpage. Any good way around this? (2 Replies)
Discussion started by: Julolidine
2 Replies

10. Shell Programming and Scripting

put a semicolon at the end of each line of a file

hi, Consider there is a file containing 200 lines. please let me know which command is to be used to put a semicolon at the end of each line. if no single command is there then how it can be achieved. (1 Reply)
Discussion started by: surjyap
1 Replies
Login or Register to Ask a Question