I would like to mention fselect which is written in Rust and uses a SQL(ish) syntax which I can remember a bit more easily:
fselect name, abspath from .
For illustrating the relevant issue with spaces and new lines as in filename posted by @ilkkachu in comments, here's an example with 2 files: a b c
and x\ny\nz
:
$ fselect name, abspath from . order by name
a b c /path/to/a b c
x
y
z /path/to/x
y
z
In fselect there is the json output which might help:
$ fselect name, abspath from . order by name into json
[{"Name":"a b c","AbsPath":"/path/to/a b c"},{"AbsPath":"/path/to/x\ny\nz","Name":"x\ny\nz"}]
This find command should work also:
find . -type f -exec basename {} \; -exec realpath {} \; | xargs -n 2
xargs -n2 helps putting the output on the same line (please see comments)
filename1
andfile1
. What am I miss-understanding?/home/../file1
and not/file1
or/home/some_user/../../file1
? also, arefilename1
,filename2
, etc symlinks?...
. Two dots (..
) means something else in a pathname, so, please, don’t use..
if you mean...
. But it would be better not to omit information at all, but just show what you mean, e.g.,/home/user347009/file1
. (2) And either make the filenames consistent or explain why they aren’t. (For example, do you meanfilename1 /home/user347009/dir1
?)