ls command

ls command

ls

In computing, ls is a command for listing computer files and directories on Unix and Unix-like operating systems. It is specified by POSIX and the Single UNIX Specification.

No hay texto alternativo para esta imagen


It is available in the EFI shell, as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of GNU Unix-like utilities, or as part of the ASCII MSX-DOS2 Tools for MSX-DOS version 2

The MATLAB and GNU Octave numerical computing environments include an ls function with similar functionality.

In other environments, such as DOS, OS/2, and Microsoft Windows, the dir command provides similar functionality.

As with most utilities, different implementations have different options. See the documentation provided with the command for the correct usage and options.

    command syntax

    ls [options] [file… | directory…]
      
                

usage example :



  usage example
  
  ls-l
  
  the -l label means long format, showing Unix file types, permissions, number of hard links, owner, group, size, last modified date and time, and name
  
  ls -l
    
  drwxr--r-- 1 fjones editors 4096 Mar 2 12:52 drafts
  -rw-r--r-- 3 fjones editors 30405 Mar 2 12:52 edit-3
  -r-xr-xr-x 1 accounting fjones 8460 Jan 16, 2022 edit.sh2

          

Additional options that control how items are displayed include:

-t sort the list by modification time. (default is alphabetically)

-c sort the list by last attribute (state) change time.

-r reverse the order, eg last time most recent.

-1 one entry per line.

among other labels .... you can review these and other tags at the following link.


An example command

The ls -l *.c command in a shell

ls -l *.c is a simple command that outputs a long list of files ending with the extension '.c' in the working directory. It's a really simple command, but the processes that happen behind the scenes are a bit more complex. Let's take an in-depth look at exactly what happens when you type 'ls -l *.c' in your shell.

This command contains three different parts, namely:

ls - command to list computer files in the current working directory.

-l - This is a flag that specifies that 'ls' should list a detailed list of files (see details such as permissions, number of hard links, owner, group, size, last modified date, and filename)

*.c – This is a wildcard specifying that only files ending in '.c' should be displayed.


Considerations to take when typing the commands and their labels.

Special consideration must be taken when typing the characters that make up the commands and their optional labels, since typing them incorrectly will cause an error in their execution.

Not only when displaying the result but also when making the command or commands work.

As you will see below typing incorrectly will give an error message.



    root:/director # ls *.
    
    ls: cannot access '*.c': no   such file or directoryc
  
            

For more information visit these websites

And do not stop reading about the creator of this command and many more things

written by: Gustavo Ponce Marsiglia

fonts: wikipedia and medium.com

--

Esteban Viana

Technical Support Analyst ES/EN/PT

2 年

Excellent article, it is quite informative and also well-written, good job.

要查看或添加评论,请登录

Gustavo Daniel Ponce Marsiglia的更多文章

社区洞察

其他会员也浏览了