- You have a space behind the
=
. This will actually make the aliaslllh
undefined (at least inbash
). - You enclosed the alias definition in backticks (
`
), probably in an attempt to create a "third layer" of quoting. However, backticks are the (albeit now deprecated) syntax for command substitution, i.e.lllh
would contain the console output of thell | awk ...
pipeline and try to execute that as a command. - You rely on a command
ll
being either present or at least pre-defined as an alias ofls -l
. This may or may not be the case. - Your
awk
program starts has the single-quotes and the curly braces in the wrong order. The correct syntax isawk ' { ... } '
.
Note that if this is part of a shell script, you may want to run it through shellcheck
, also available as standalone tool on many Linux distributions, to catch many syntax-related errors.
alias ll="lslh="ls -lh | awk '{print \$9, \"-\" ,\$5, \"-\", \$8, \"-\",\$7, \$6}'"
the advice found in one of the answers to the question you linked - defining a function - is a far better way to get out of the "quoting hell" (as mentioned by @ilkkachu), so something like
lh() { ls -lh | awk '{print $9, "-" ,$5, "-", $8, "-",$7, $6}'; }
is much cleaner and easier to understand
I would recommend to avoid parsing
ls
altogether, and propose the followingfind
-based alias instead:lh() { find . -maxdepth 1 -type f ! -name ".*" -printf "%f - %s - %TY - %Td %Tb\n"; }
which uses the
printf
formatting options offind
to reliably output the desired file properties. The only drawback is that there is no-h
option for human-readable sizes.The
! -name ".*"
filter is used to emulate the standard behavior ofls
to ignore hidden files. If you want them listed, you can leave that part out.