Use of tr command to translate after 1st character of each line in a file

Hello,

I have an input file contaning following data:

< 12345;5454;77;qwert< yuyuy;ruwuriwru> yyyw;
> 35353;68686;424242;hrjwhrwrwy< dgdgd;

I have first character as '<' or '>'and after that one space is their in each line

I just want to replace 1st space encountered after < or > in a file with ; symbol

output should be like this:

<;12345;5454;77;qwert< yuyuy;ruwuriwru> yyyw;
>;35353;68686;424242;hrjwhrwrwy< dgdgd;

Thanks in advance

Hello abhi001cse;
Welcome to forum, please use code tags while posting codes and commands.
Following awk solution may help you.

awk -F";" '{sub(/ /,";",$1);print}' OFS=";" Input_file

Output will be as follows.

<;12345;5454;77;qwert< yuyuy;ruwuriwru> yyyw;
>;35353;68686;424242;hrjwhrwrwy< dgdgd;

Thanks,
R. Singh

1 Like

Thanks a lot Ravinder.Its working fine

how about

sed -r 's/^(<|>) /\1;/' file

btw: you can't use tr for that; it will replace ALL occurrences, not just the first.