How to repeat a character in a field if it's a single character?


Login or Register to Reply

 
Thread Tools Search this Thread
# 8  
Code:
$ awk -F, -v OFS=, ' { sub("^.$","&&",$1) } 1 ' file
CC,rs18768
GG,rs13785
GA,rs1065
GG,rs1801279
TT,rs9274407
AA,rs730012

This User Gave Thanks to anbu23 For This Post:
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
awk sed to repeat every character on same position from the upper line replacing whitespace
nakaedu
Hello is it possible with awk or sed to replace any white space with the previous line characters in the same position? I am asking this because the file I have doesn't always follow a pattern. For example the file I have is the result of a command to obtain windows ACLs: icacls C:\ /t...... Shell Programming and Scripting
5
Shell Programming and Scripting
Replace a field with a character as per the field length
gani_85
Hi all, I have a requirement to replace a field with a character as per the length of the field. Suppose i have a file where second field is of 20 character length. I want to replace second field with 20 stars (*). like ******************** As the field is not a fixed one, i want to do the...... Shell Programming and Scripting
2
Shell Programming and Scripting
Replace multiple occurances of same character with a single character.
dipanchandra
Hi all, Greetings, I have the following scenario, The contents of main file are like : Unix|||||forum|||||||||||||||is||||||the||best so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it And i need the output in the following form: Unix=forum=is=the=best so=be=on=it ...... Shell Programming and Scripting
3
Shell Programming and Scripting
Count number of occurences of a character in a field defined by the character in another field
s052866
Hello, I have a text file with n lines in the following format (9 column fields): Example: contig00012 149606 G C 49 68 60 18 c$cccccacccccccccc^c I need to count the number of lower-case and upper-case occurences in column 9, respectively, of the...... Shell Programming and Scripting
3
Shell Programming and Scripting
repeat character with printf
ripat
It's all in the subject. I try to figure out how to repeat a character a number of time with printf. For example to draw a line in a script output. Thks... Shell Programming and Scripting
13
Shell Programming and Scripting
Red Hat Linux

Red Hat, Inc. is a global American software company providing open-source software products to the enterprise community. Red Hat was Founded in 1993, and has its corporate headquarters in Raleigh, North Carolina, with other offices worldwide. On October 28, 2018, IBM announced its intent to acquire Red Hat for $34 billion. Red Hat has focused on Red Hat Enterprise Linux an enterprise operating system. Red Hat also acquired the open-source enterprise middleware vendor JBoss. Red Hat also sells an enterprise virtualization product, Red Hat Virtualization (RHV). Red Hat also provides storage, operating system platforms, middleware, applications, management products, and support, training, and consulting services. Red Hat actively creates, maintains, and contributes to many free and open software projects. Red Hat has acquired several proprietary software products through corporate mergers and acquisitions and has released these software acquisitions under open-source licenses.
Please enjoy and help our forum community by "showing your work" and posting your code, even when your code is not working as expected. To help others help you, please wrap your code blocks, sample input, sample output, error messages, and other data in CODE tags and wrap your short commands and short data objects in ICODE tags. We were all beginners in the beginning. If you have any questions about how to register or how to post, please contact us in Live Chat. Thank you and enjoy this "forever free" technical support community for UNIX, Linux and computer information technology in general.