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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:48:21+00:00 2026-05-28T01:48:21+00:00

My goal is to cut the output of a command down to an arbitrary

  • 0

My goal is to cut the output of a command down to an arbitrary number of characters (let’s use 6). I would like to be able to append this command to the end of a pipeline, so it should be able to just use stdin.

echo "1234567890" | your command here 
# desired output: 123456

I checked out awk, and I also noticed bash has a substr command, but both of the solutions I’ve come up with seem longer than they need to be and I can’t shake the feeling I’m missing something easier.

I’ll post the two solutions I’ve found as answers, I welcome any critique as well as new solutions!


Solution found, thank you to all who answered!

It was close between jcollado and Mithrandir – I will probably end up using both in the future. Mithrandir’s answer was an actual substring and is easier to view the result, but jcollado’s answer lets me pipe it to the clipboard with no EOL character in the way.

  • 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-28T01:48:22+00:00Added an answer on May 28, 2026 at 1:48 am

    Do you want something like this:

    echo "1234567890" | cut -b 1-6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My goal here is to cut down the number of cookies I'm using to
Goal I am building an Eclipse plugin targeting the 3.7 environment and would like
Goal Let me start with my final vision of what I'd like to be
I would like to split a line such as: name1=value1,name2=value2, .....,namen=valuen two produce two
Goal To create an array of Model’s, managed by an ArrayController (ArrayProxy). Requirements Use
My goal is to know when a user presses the cut, copy, paste, or
I would like to pass some options to a compiler. The option would have
Goal: Given a number (it may be very long and it is greater than
Goal : Add the latest JSON into my project. I download JSON from this
Goal: I want to use the Observer Pattern so that when one uiimageview receives

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.