Check your single quotes. Single quotes don't magically nest.
alias sll 'ls -l \!* | grep -oE '\''[^ ]+$'\'' | xargs ls -ld --'
That's still flawed for several reasons:
- Because of
[^ ]
, that won't work for file or link target names that contain spaces.
- as you're treating that list as a list of lines, that won't work with file/link target names that contain newline characters.
- because of
xargs
, that won't work with file/target names containing apostrophes, backslashes, double quotes, other types of blanks.
- For symlinks with relative paths as their targets, that only works for symlinks in the current directory as what you pass to the second
ls
is a relative path to the current directory, while symlinks are resolved relative to the path of the symlink file (if you have a a/b/c -> d
link, that's to a/b/d
, not d
in the current directory).
- you'll get a spurious error message because of the first
total <n>
line of the output of ls
.
- for symlinks to symlinks, that won't give you the same as
ls -lL
(may be what you want though).
With zsh
, you could make it:
ls -ld -- *(:A)
The :A
modifier expands symlinks to their canonical absolute path.
A quasi-equivalent on GNU systems:
readlink -fz -- * | xargs -r0 ls -ld --