In Solaris (>= 10) the ls command has the -E option. So your command could be as simple as
ls -E /etc/hosts
or
ls -E /etc/hosts | awk '{print $6}'| sed 's#-##g'
to get the desired result.
PuTTY doesn't do that. It's a feature of xterm, and is one of many features of xterm not provided by PuTTY: sending different escape sequences depending on whether the Control and/or Shift key is pressed at the same time.
xterm-style modifiers for cursor keys are supported in ncurses by a extended terminal description (not part of conventional X/Open or SVr4 terminfo). However, PuTTY does not implement xterm-style modifiers in this case. For a long time, it used the Shift key to switch between normal and application modes for the cursor keys, and recently changed the modifier to the Control key:
commit 41e1a586fb956539a74bc446984a100e0138cd77
Author: Simon Tatham
Date: Sat Dec 8 08:25:32 2018 +0000
- swapping the arrow keys between normal (ESC [ A) and application
(ESC O A) is now done by pressing Ctrl with them, and _not_ by
pressing Shift. That was how it was always supposed to work, and
how it's worked on GTK all along, but on Windows it's been done by
Shift as well since 2010, due to a bug at the call site of
format_arrow_key() introduced when I originally wrote that function.
but that did not change the escape sequence used. In the change comment, ESC [ A
refers to the normal-mode up-arrow, and ESC O A
to the application-mode up-arrow.
ncurses provides an accurate terminal description for PuTTY, but in this case the terminal description is irrelevant because bash uses hard-coded escapes in .inputrc
(zsh does a little better, but also is lacking in this area--see the xterm manual). Even supposing that bash used the terminal description, the information is not available to bash because the terminal description's names cannot be read using a termcap application (such as bash). As mentioned, zsh is a little better, but it does not read extensions.
Using
infocmp -x xterm
you might notice kLFT5
, kRIT5
, kUP5
, kDN5
(which are the names given to the control-modified cursor keys--all extensions), but you will not find those in the putty
terminal description because PuTTY doesn't do that.
Best Answer
Note that it has nothing to do with Linux; that
-printf
predicate is specific to the GNU implementation offind
. Linux is not an OS, it's just the kernel found in a number of OSes. While most of those OSes used to use a GNU userland in the past, now the great majority of OSes using Linux are embedded and have basic commands if they have any.The GNU
find
command, which predates Linux, can be installed on most Unix-like OSes. It was certainly used on Solaris (called SunOS back then) before Linux came out.Nowadays, it's even available as an Oracle package for Solaris. On Solaris 11, that's in
file/gnu-findutils
, and the command is namedgfind
(for GNUfind
, to distinguish it from the system's ownfind
command).Now, if you can't install packages, your best bet is probably to use
perl
:Here, we're still using
find
(Solaris implementation) to find the files, but we're using its-exec
predicate to pass the list of files toperl
. Andperl
does alstat()
on each to retrieve the file metadata (including the modification time as the 10th element ($s[9]
)), interprets it in the local timezone (localtime()
) and formats it (strftime()
) which it thenprint
s alongside the file name ($_
is the loop variable if none is specified inperl
, and$!
is the equivalent ofstderror(errno)
, the error text for the last system call failure).