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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:15:34+00:00 2026-06-12T03:15:34+00:00

I have an example [file] that I want to Grab lines 3-6 and lines

  • 0

I have an example [file] that I want to Grab lines 3-6 and lines 11 – 13 then sort with a one line command and save it as 3_6-11_13. These are the commands I have used thus far but I haven’t gotten the desired output:

sed -n '/3/,/6/p'/11/,/13/p file_1 > file_2 | sort -k 2 > file_2  & sed -n 3,6,11,13p file_1 > file_2 | sort -k 2 file_2.

Is there a better way to shorten this. I have thought about using awk but have I stayed with sed so far.

  • 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-12T03:15:35+00:00Added an answer on June 12, 2026 at 3:15 am

    With sed you’re allowed to specify addresses by number like so:

    sed -n '3,6p'
    

    The -n is to keep sed from automatically printing output.

    Then you can run multiple commands if you’re using gsed by separating those commands with semicolons:

    sed -n '3,6p; 11,13p' | sort -k2 > 3_6-11_13
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file with .php extention www.example.com/thefile.php?name=123 that I want to direct the
I have an XML file that I want to sort by an attribute. The
I have example.xlsx file that contains some data. I want to show the data
I have for example .pdf file (path to that file). How to open this
Suppose I have a example.php file like that: <p> <?php echo _('Hello world') ?>
I have a data file that looks like the following example. I've added '%'
I currently have a csv file that I'm parsing with an example from here:
For example, I have a txt file that reads: 12 345 45 2342 234
For example, let's say I have a Maven build file that has dependencies located
For example, I have a piece of code that's generating a SQL*Loader control file

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.