First of all, this is not a duplicate of this: Linux ls to show only filename date and size
Because I want to print actual directory name additionally.
I was always using this command:
ls -l | awk '{print $5, $9}'
to get the each file size and name.
But now, I need to print the file directory additionally.
Is that possible?
Best Answer
You mean like this, just prepending the current directory to each filename?
(the
-v
just imports the$PWD
shell variable into the awk script).Or something else?
OK, apparently what you want is
Is that correct?
If so, the change you need is this:
If you have an older shell, the
$()
may not work, in which case try:instead. I don't have immediate access to any shell that doesn't support
$()
, but I can't think where else yourIllegal variable name
error would come from, when this works for me.If it still doesn't work, please describe your platform, shell, version of awk etc. in your question - the comment thread is getting pretty long and I'm running out of guesses :-)