Using ls command to display the order of files
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2006
    Posts
    1,668
    Linux (Fedora) Chrome 71.0.3578.98

    Using ls command to display the order of files

    Hi Friends,

    I am using Fedora 27 Workstation. I need some help with ls command. I have one folder with photos copied from my Samsung mobile. I have sorted them by First Modified criteria, but when I run the ls command with various flags they are not displayed in the same order as they are ie image titled "image 151.jpg" should be first, "image 152.jpg" should be second and so on. I have attached a link to a few screenshots to help you get to the bottom of this. Please guide me. Wishing everyone a belated happy new year. Thanks.


    https://imgur.com/a/DV88UTR
    fedoralinuxcommands.blogspot.com


    All the forces in the world are not so powerful as an idea whose time has come - Victor Hugo

  2. #2
    Join Date
    Aug 2014
    Location
    France
    Posts
    37
    Linux (Fedora) Firefox 64.0

    Re: Using ls command to display the order of files

    Hi,
    all CLI commands come with a man page. Type "man ls" and you get your answer.
    In this case : "ls -t"
    --
    no shame not knowing
    only not learning

  3. #3
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    767
    Linux (Ubuntu) Firefox 64.0

    Re: Using ls command to display the order of files

    Quote Originally Posted by Nednet
    In this case : "ls -t"
    Actually "ls -tr", otherwise 151 would be last not first.

  4. #4
    Join Date
    Apr 2018
    Location
    Finland
    Posts
    111
    Linux Chrome 71.0.3578.98

    Re: Using ls command to display the order of files

    You could pipe output to sort
    Code:
    ls | sort -n -k2
    ls -l | sort -n -k10

  5. #5
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    767
    Linux (Ubuntu) Firefox 64.0

    Re: Using ls command to display the order of files

    Quote Originally Posted by keikari
    You could pipe output to sort
    Code:
    ls | sort -n -k2
    ls -l | sort -n -k10
    That would only work in the example above though as the alphanumeric names are also in date order, for non-date ordered names it wouldn't work as expected.

Similar Threads

  1. order of files and folders in nautilus
    By udo in forum Using Fedora
    Replies: 2
    Last Post: 14th July 2013, 04:41 PM
  2. [SOLVED]
    What is the command to edit Fedora boot order?
    By Gumptron in forum Installation, Upgrades and Live Media
    Replies: 4
    Last Post: 1st November 2011, 06:50 AM
  3. Order - invalid command at Apache startup?!?!
    By misjka in forum Servers & Networking
    Replies: 4
    Last Post: 23rd September 2006, 10:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •