Modifying individual text fields in Bash Script

In this tutorial, How do i modifying individual text fields in bash script? Bash Script the essential for DevOps Roles.

  • Input: string is “HHHHHHHH
  • Output: AHHHHHHH, BHHHHHHH, CHHHHHHH, DHHHHHHH, XHHHHHHH, ZHHHHHHH

Bash script modifying individual text fields

#!/bin/bash
STRING="HHHHHHHH"
COUNT=1
echo "Input: $STRING"
while [ "$COUNT" -le "${#STRING}" ]; do
   for i in A B C D X Y Z
   do
       printf '%s%s%s\n' "${STRING:0:COUNT-1}" "$i" "${STRING:COUNT}"
   done
   COUNT=$(( COUNT + 1 ))
   break
done

The screen output terminal as below

[vagrant@app1 ~]$ ./bashscript.sh
Input: HHHHHHHH
AHHHHHHH
BHHHHHHH
CHHHHHHH
DHHHHHHH
XHHHHHHH
YHHHHHHH
ZHHHHHHH
Modifying individual text fields in Bash Script

For example, You delete break line in loop while 🙂 

Modifying individual text fields in Bash Script

The result, delete break line in loop while as below

Modifying individual text fields in Bash Script

Conclusion

Thought the article, You can “Modifying individual text fields in Bash Script“ as above. I hope will this your helpful.

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.