Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:48:26+00:00 2026-05-27T00:48:26+00:00

I have a significantly large string that that I need to format so that

  • 0

I have a significantly large string that that I need to format so that no more than 16 bytes are shown on each line. I used the for loop to go up 16 bytes but then the script stops parsing the remaining string. I need to add a new line after 16th byte so that then next 16 bytes continue on the next line.

$ echo "45a000531ee1000036118b9472041523cb5c8701084b084b003ff3443213002f8445f0a4a3d7000001800e291053dbe7157faa3ea02f850004720415238500047cc3685387000c020b921f7196979774f9000000" 
|  sed 's/../ &/g' | sed 's/^ //' 
| awk 'ORS="\n"{ for (i=1; i<17;i++) printf ("%s ", $i)}'
45 a0 00 53 1e e1 00 00 36 11 8b 94 72 04 15 23

Solution: (Courtesy: Chris)

awk 'NF{gsub(/.{16}/,"&\n",$0);print $0}' text | sed 's/../ &/g' | sed 's/^ //g'    
45 a0 00 53 1e e1 00 00    
36 11 8b 94 72 04 15 23    
cb 5c 87 01 08 4b 08 4b     
00 3f f3 44 32 13 00 2f     
84 45 f0 a4 a3 d7 00 00     
01 80 0e 29 10 53 db e7     
15 7f aa 3e a0 2f 85 00     
04 72 04 15 23 85 00 04      
7c c3 68 53 87 00 0c 02      
0b 92 1f 71 96 97 97 74      
f9 00 00 00
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:48:27+00:00Added an answer on May 27, 2026 at 12:48 am

    try:

    command:

    echo "yourLongString" | sed 's/.\{16\}/&\n/g' 
    

    output:

    45a000531ee10000
    36118b9472041523
    cb5c8701084b084b
    003ff3443213002f
    8445f0a4a3d70000
    01800e291053dbe7
    157faa3ea02f8500
    0472041523850004
    7cc3685387000c02
    0b921f7196979774
    f9000000
    

    EDIT:

    Or with gawk:

    gawk 'NF{gsub(/.{16}/,"&\n",$0);print $0}'
    

    HTH Chris

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large file where each line contains space-separated integers. The task is
I have a View that can vary significantly, depending on the 'mode' a particular
I have a test that compares a large blob of expected XML with the
I have a table that stores the summed values of a large table. I'm
We have a large set of tests running against an in memory database. Each
OK, so things have progressed significantly with my DSL since I asked this question
I have a varchar field in my database which i use for two significantly
I am told that the configuration below is possible, but have had significant difficulty
We have a mid-size SQL Server based application that has no indexes defined. Not
So I have a problem that I can not figure out. I am writing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.