Ls: Difference between revisions
From Leechfinger
Jump to navigationJump to search
Leechfinger (talk | contribs) No edit summary |
Leechfinger (talk | contribs) No edit summary |
||
Line 16: | Line 16: | ||
// or sort by version | // or sort by version | ||
$ ls -lgo --sort=version | $ ls -lgo --sort=version | ||
</syntaxhighlight> | |||
=== Delete files using inode === | |||
<syntaxhighlight lang="bash"> | |||
qais@hdpdt01:~$ mkdir junk | |||
qais@hdpdt01:~$ cd junk | |||
qais@hdpdt01:~/junk$ ls | |||
qais@hdpdt01:~/junk$ touch hello | |||
qais@hdpdt01:~/junk$ ls -la | |||
total 8 | |||
drwxr-xr-x 2 qais qais 4096 May 3 13:25 . | |||
drwx------ 42 qais qais 4096 May 3 13:25 .. | |||
-rw-r--r-- 1 qais qais 0 May 3 13:25 hello | |||
qais@hdpdt01:~/junk$ ls -i | |||
175965192 hello | |||
qais@hdpdt01:~/junk$ find . -maxdepth 1 -type f -inum 175965192 | |||
./hello | |||
qais@hdpdt01:~/junk$ find . -maxdepth 1 -type f -inum 175965192 -delete | |||
qais@hdpdt01:~/junk$ ls -la | |||
total 8 | |||
drwxr-xr-x 2 qais qais 4096 May 3 13:26 . | |||
drwx------ 42 qais qais 4096 May 3 13:25 .. | |||
qais@hdpdt01:~/junk$ | |||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Commands]] | [[Category:Commands]] |
Revision as of 18:28, 3 May 2025
"ls" is the list directory command, below are some of the flags we normally use.
Show only directories
$ ls -d */
Don't show group and owner
$ ls -lgo
Newest files first
$ ls -lt
File size and sort
$ ls -sSh
Show modification time
$ ls -lgot --time-style=long-iso
Sorting files by extension/version
$ ls -lgo --sort=extension
// or sort by version
$ ls -lgo --sort=version
Delete files using inode
qais@hdpdt01:~$ mkdir junk
qais@hdpdt01:~$ cd junk
qais@hdpdt01:~/junk$ ls
qais@hdpdt01:~/junk$ touch hello
qais@hdpdt01:~/junk$ ls -la
total 8
drwxr-xr-x 2 qais qais 4096 May 3 13:25 .
drwx------ 42 qais qais 4096 May 3 13:25 ..
-rw-r--r-- 1 qais qais 0 May 3 13:25 hello
qais@hdpdt01:~/junk$ ls -i
175965192 hello
qais@hdpdt01:~/junk$ find . -maxdepth 1 -type f -inum 175965192
./hello
qais@hdpdt01:~/junk$ find . -maxdepth 1 -type f -inum 175965192 -delete
qais@hdpdt01:~/junk$ ls -la
total 8
drwxr-xr-x 2 qais qais 4096 May 3 13:26 .
drwx------ 42 qais qais 4096 May 3 13:25 ..
qais@hdpdt01:~/junk$