Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

short question 2

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL

ASSSFDSF
SDFSGDSFGS
SDFSGSFSS
SFDSFSFSF
SDFSFSFS


I am looking for a quick way to process above and get output:

AS-SSFDSF
SD-FSGDSFGS
SD-FSGSFSS
SF-DSFSFSF
SD-FSFSFS


thank you in advance.
 
Hi

Code:
awk '{sub(/../,"&-")}1' /input/file

[gray]# or[/gray]

awk '{print substr($0,1,2)"-"substr($0,3)}' /input/file

[gray]# or gawk only[/gray]

awk '{print gensub(/(..)/,"\\1-","")}' /input/file

Feherke.
 
One way:
sed 's!^\(..\)!\1-!' /path/to/input > output

OOps, awk forum:
awk '{print substr($0,1,2)"-"substr($0,3)}' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top