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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:06:40+00:00 2026-05-26T02:06:40+00:00

Title my be ambiguous. Here’s an example of what I’m asking. #ls -l prints

  • 0

Title my be ambiguous. Here’s an example of what I’m asking.

#ls -l

prints me out something like this

-rw-r--r-- 1 root root   5110 2011-10-08 19:36 test.txt
-rw-r--r-- 1 root root   5111 2011-10-08 19:38 test.txt
-rw-r--r-- 1 root root   5121 2011-10-08 19:36 5110.txt
-rw-r--r-- 1 root root   5122 2011-10-08 19:38 5111.txt

Say I wanted to use grep to find all filenames containing '511' and print out the size/filename of the file.

How do I grep for filenames '511', still print the filesize, and not have the output contain the top two rows.

thank you very much SO, reading man pages hasn’t helped me on this one.

  • 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-26T02:06:41+00:00Added an answer on May 26, 2026 at 2:06 am

    You can use awk for this:

    pax:~$ echo '
    -rw-r--r-- 1 root root   5110 2011-10-08 19:36 test.txt
    -rw-r--r-- 1 root root   5111 2011-10-08 19:38 test.txt
    -rw-r--r-- 1 root root   5121 2011-10-08 19:36 5110.txt
    -rw-r--r-- 1 root root   5122 2011-10-08 19:38 5111.txt
    ' | awk '{if (substr($8,1,3)=="511"){print $5" "$8}}'
    
    5121 5110.txt
    5122 5111.txt
    

    It simply checks field 8 (the filename) to see if it starts with “511” and, if so, prints out fields 5 and 8, the size and name.

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

Sidebar

Related Questions

Not exactly sure how to phrase this, sorry for ambiguous title. Anyways, here's basically
All, Sorry in advance for the ambiguous title. Here's what I'm trying to do...
So the title is a tad ambiguous, but I'll try and give an example.
Sorry if the title is still ambiguous. I'm doing this assignment for school and
Sorry for the ambiguous title, but this is a strange issue. I'm using the
Apologies if the title is ambiguous, but I could not figure out a good
Sorry for the ambiguous title. I'm reading this book http://algs4.cs.princeton.edu/home/ and I thought it
I'm sorry for ambiguous title, but this question is hard for me to put
Maybe the title of this question is ambiguous, what I really mean is: #footer_list
Sorry for the ambiguous title; but I don't now how to describe it different.

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.