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

  • Home
  • SEARCH
  • 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 362323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:14:00+00:00 2026-05-12T13:14:00+00:00

How would I get awk to output the whole file name in ls -l

  • 0

How would I get awk to output the whole file name in ls -l if some of the files have spaces in them. Usually, I can run this command:

ls -l | awk '{print $9}'

That doesn’t work if the files have spaces in them. Is it possible to print $9, $10, $11 etc as well somehow?

  • 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-12T13:14:00+00:00Added an answer on May 12, 2026 at 1:14 pm

    A better solution: Don’t attempt to parse ls output in the first place.

    The official wiki of the irc.freenode.org #bash channel has an explanation of why this is a Bad Idea, and what alternate approaches you can take instead: http://mywiki.wooledge.org/ParsingLs

    Use of find, stat and similar tools will provide the functionality you’re looking for without the pitfalls (not all of which are obvious — some occur only when moving to platforms with different ls implementations).

    For your specific example, I’m guessing that you’re trying to find only files (and not directories) in your current directory; your current implementation using ls -l is buggy, as it excludes files which have +t or setuid permissions. The Right Way to implement this would be the following:

    find . -maxdepth 1 -type f -printf '%f\n'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please shed some light on how I would get this to work:
How would get find an average from an array? If I have the array:
Could someone supply some code that would get the xpath of a System.Xml.XmlNode instance?
I'm trying to write a recursive function that would get some string, as well
Can anyone enlighten me in what scenarios I would get the following error in
I'm making a little iphone game, and I would get some clues. Let's imagine:
In some script, it reads the directory name and get things like 66.9090_89.4450_168.0250_ABC3/ I
I would like get last non-blank line from a file using sed. I was
I am trying to write an awk script that can get a block that
I have CSVs like this: apple,file1.txt banana,file1.txt carrot,file2.txt How can I get it to

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.