regex


How to double digits using sed command in Unix?


I'm new to the Unix sed command and I would like to know how to double the first digit in a string?
Suppose we have a string "F0o", How do I double the first digit in the string?
I tried echo f0o | sed s/0/00/, giving f00o,
but this will only work for 0s. If the string is "f12o" the output should be f112o, simply doubling the first digit in the string.
Is there a command where I can specifically target digits only?
I would like to know how to double the first digit in a string
You could say:
sed 's/[0-9]/&&/' filename
This would print the first digit in a line two times.
$ sed 's/[0-9]/&&/' <<< "f12o"
f112o

Related Links

RegEx in perl that Uses Groups to Extract Information From A Filepath
nginx, redirect to remove a part of filename
How to grep the second number only in one line?
find first and last occurence of the matched string in perl
Regex select pattern
regular expression Pattern object getting converted to string if fetched from config.cfg file
Dynamically-created 'zip' command not excluding directories properly
Groovy regexes and wildcard permissions
Regular expression to verify a username
match an IP against a regular expression with CIDR range
Bash script - user inputs 2 digits seperated by a space; need to verify it's a digit
Using ampersand in sed
Remove all instances of sub-string after a different sub-string has occurred N times
How to replace “\” to “T” using regex?
parse text into sentences via regex
Regex for 9-digit phone number dot-separated

Categories

HOME
ios
groovy
redirect
clojure
lua
android-sqlite
rtmp
afp
windows-runtime
wikipedia
antlr4
ionic3
phpmailer
py.test
light-inject
proftpd
sonata-admin
vulkan
avr
jsqmessagesviewcontroller
lexikjwtauthbundle
freetype
slime
rtp
windows-applications
netlify
google-distancematrix-api
broker
iteration
fat-free-framework
iar
reformatting
solarwindslem
popupwindow
pymysql
magento2.0.2
swipe
ollydbg
google-crawlers
nav
outlook-vba
api-doc
extraction
xaf
jetty-9
texture-mapping
partition
psychopy
compass-lucene
word-embedding
syncfusion
freerdp
integer-programming
rating-system
soql
libev
html-lists
fasta
webloadui
configuration-profile
error-correction
flattr
xpdf
agents-jade
hyperterm
finalcut
geneos
isapi-rewrite
android-popupwindow
balana
js-of-ocaml
readline
folder-structure
cocoon-gem
gulp-protractor
multiscreen
avalonedit
google-swiffy
omap
byte-order-mark
janino
conditional-statements
horizontalscrollview
cvs2git
tab-delimited
esx
typesafe-activator
tinkerpop-frames
wmv
dirpagination
nawk
jquery-mobile-popup
simpleaudioengine
wow64
asp.net-authentication
shebang
locomotivejs
jcycle
blackberry-cascades
timestamp-with-timezone
working-directory
force.com
quilt
httpconnection
consistent-hashing
bapi
mdi
ladon
codi
regexbuddy
unitils
spquery
polyglot
geneva-framework
metaphone

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App