Listing files / directories with full path of query


December 8, 2023

Have you ever noticed that ls sometimes provides relative path, while other times uses full path?

$ ls ~/.config/nixpkgs
config.nix

$ ls ~/.config/nixpkgs/*  # append wildcard suffix
/home/wilson/.config/nixpkgs/config.nix

The program ls actually is unaware of the trailing * because the current shell expanded the operator then passed the list of files. From the perspective of ls, the two commands below are the same.

$ ls ~/.config/nixpkgs/*
/home/wilson/.config/nixpkgs/config.nix

$ ls ~/.config/nixpkgs/config.nix
/home/wilson/.config/nixpkgs/config.nix

Thanks for reading. More like this?

#til #linux

© 2023-2025 Wilson Husin

This site was last updated 2025-05-17T20:42:58-0700.

:wq