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 7943581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:18:44+00:00 2026-06-04T00:18:44+00:00

How to alter the string format of the text between the line number and

  • 0

How to alter the string format of the text between the line number and the history entry in the output of history in bash?

If running history in bash prints, for example:

5  history

how to change that to this, for instance:

5....history

or

5_anyString_history

Also, alignment is done by history already, by adjusting the number of spaces. How to include this functionality as well? That is, if . is used as the string, how to change the number of dots according to the number of digits in the line number? Also, I’d like to remove the leading spaces.

  • 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-06-04T00:18:45+00:00Added an answer on June 4, 2026 at 12:18 am
    history | sed 's/^\( *[0-9]*\) */\1../'
    

    When I do history, there is always two spaces after the line number. The alignment is done by varying the number of spaces before the number.

    This is an example of how to replace the leading spaces (which vary in number):

    history | sed 's/^ */&\n/; :a; s/ \(.*\n\)/.\1/; ta; s/\n//'
    

    Edit:

    This version works similarly to the second one above, but it moves the dots after the numbers so there are no leading spaces and the variable number of dots cause the history entries to be left aligned.

    sed 's/^ */&\n/; :a; s/ \(.*\n\)/.\1/; ta; s/\n//;s/\(\.*\)\([^ ]*\) */\2\1/'
    1....aaa bbb ccc
    22...ddd eee fff
    333..ghi jkl mno
    

    This is how it works:

    • add a newline after the initial sequence of spaces (divide and conquer)
    • :a – label for branching
    • replace one space before the newline with a dot
    • ta – branch to label :a if a replacement is made, once all the leading spaces are replaced, continue past the branch instruction
    • remove the newline
    • capture the dots and non-spaces (digits) in two capture groups and exclude the spaces after the numbers
    • and swap the two groups (so the dots now come after the numbers)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

adsSearch.FilterExpression = string.Format([Product Title] = '{0}', TextBox1.Text); DataView dv = (DataView)adsSearch.Select(DataSourceSelectArguments.Empty); if (dv.Count >
Using String.Format how can i ensure all numbers have commas after every 3 digits
Extract the number after #/ from my string: abcdefg#/123 .
After reading about the problem of passing empty std::string objects between DLLs and EXEs,
I've got the following string: [global::System.CodeDom.Compiler.GeneratedCodeAttribute(System.Data.Design.TypedDataSetGenerator, 2.0.0.0)] I need to alter it to look
I have the following string format in a Sql table column [CID]: 267 [MID]:
Let's say I have an input text file of the following format: Section1 Heading
There are a number of run-time differences in compatible code between these two versions
The situation: I’ve an external DLL that uses UTF-8 as its internal string format.
I have a string in the following format in a comma delimited file: someText,

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.