Skip to main content

Thread: Script to replace characters in text file


i have odd request, lets have text file this:
code:
__##___##___iiiiii  __##___##_____ii__  __##___##_____ii__  __#######_____ii__  __##___##_____ii__  __##___##_____ii__  __##___##___iiiiii
i want script replace of hash tabs random characters.

found command generate random character
apg -a1 -n1 -m1 -x1 -d
so guess need know how script search , replace using random character upon each successive find until end of file occurs. can me this?

this kinda works
#!/bin/bash
j in {1..31}
do
char=`apg -a1 -n1 -m1 -x1 -d`
echo $char
sed -i '0,/#/s/#/'$char'/' test.txt
done
resulted in this... wanted.
__qj___h;___iiiiii
__o1___=<_____ii__
__vs___y:_____ii__
__,=vr~?8_____ii__
__+~___>8_____ii__
__y*___+}_____ii__
__tu___3#___iiiiii


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help Script to replace characters in text file


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support