The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 20,994β€…    Votes:  3β€…
Tags: command-line   bash  
Link: πŸ” See Original Answer on Ask Ubuntu ⧉ πŸ”—

Title: Is it possible to list only the filename and size for each file in a directory using only options found in the ls utility?
ID: /2019/11/04/Is-it-possible-to-list-only-the-filename-and-size-for-each-file-in-a-directory-using-only-options-found-in-the-ls-utility_
Created: November 4, 2019
Upload: March 3, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false

It’s impossible to do with the ls command by itself. You can do it by piping ls -l output to other commands or with a totally different command like find as others have answered.

The tree command gives another alternative:

rick@alien:~/askubuntu$ tree -h
β”œβ”€β”€ [8.8K]  aptfielout
β”œβ”€β”€ [1.8K]  aptfilein
β”œβ”€β”€ [ 435]  aptfileout
   (... SNIP ...)
β”œβ”€β”€ [  38]  script
β”œβ”€β”€ [4.0K]  subdir-A
β”‚Β Β  β”œβ”€β”€ [  14]  1.mp4
β”‚Β Β  β”œβ”€β”€ [  14]  2.mp4
β”‚Β Β  β”œβ”€β”€ [  14]  3.mp4
β”‚Β Β  └── [4.0K]  JSON
β”‚Β Β      └── [4.0K]  JSON
β”‚Β Β          β”œβ”€β”€ [   7]  1.json
β”‚Β Β          β”œβ”€β”€ [   7]  2.json
β”‚Β Β          β”œβ”€β”€ [   7]  3.json
β”‚Β Β          └── [   7]  4.json
   (... SNIP ...)
β”œβ”€β”€ [1.5K]  ttlus
└── [1.3K]  ttlus~

7 directories, 57 files

The tree option passed is -h for human readable size. For size in exact bytes pass -s.

⇧ Why can't I set a default output audio device in Ubuntu 19.10? How do I check the status of the CMOS battery?  β‡©