Discussion:
Use ls to sort directories by time of modification of contents?
Add Reply
The Real Bev
2018-08-04 22:25:51 UTC
Reply
Permalink
Raw Message
My go-to ls command is ls -altGF --color=yes |more. It does just what
I want with files, but directories stubbornly retain their creation
dates rather than the date on which a file contained therein was modified.

Is there any way to sort the way I want? I ask here because slackware
is frequently just DIFFERENT from the more popular distros.
--
Cheers, Bev
"History started badly and hav been geting steadily worse."
-- Nigel Molesworth
The Real Bev
2018-08-04 23:11:46 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
My go-to ls command is ls -altGF --color=yes |more. It does just what
I want with files, but directories stubbornly retain their creation
dates rather than the date on which a file contained therein was modified.
Is there any way to sort the way I want? I ask here because slackware
is frequently just DIFFERENT from the more popular distros.
Touch will change the directory date, but that's kind of cumbersome and
not reliable. Well, actually, *I*'m not reliable :-(
--
Cheers, Bev
Of course SoCal has four seasons:
Earthquake, Mudslide, Brushfire, and Riot
Joe Rosevear
2018-08-05 04:48:44 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
My go-to ls command is ls -altGF --color=yes |more. It does just what
I want with files, but directories stubbornly retain their creation
dates rather than the date on which a file contained therein was modified.
Is there any way to sort the way I want? I ask here because slackware
is frequently just DIFFERENT from the more popular distros.
Howdy,

The problem with your request is that it doesn't quite make sense.
Directories are rather like files. They have creation dates and times.
I don't think a directory has a modification date or time, although
someone else might correct me. Even if it did, what would it mean? A
directory is an entity that is independent of the files that are in it.

Files do have modification dates and times.

Would a list of all your files across sub-directories and sorted by
date and time help? Armed with such a list you could quickly determine
which directory contained the *file* with the oldest or youngest
modification.

Anyway, it was fun coming up with this, possibly not helpful, answer to
your question. So here it is:

du . -a --time --time-style +%s\ %y%m%d\ %H:%M | sort -k 2 -n | less -R

Or if you prefer more to less:

du . -a --time --time-style +%s\ %y%m%d\ %H:%M | sort -k 2 -n | more

This is the du command, not ls. I chose du, because I knew it could
give me file listings that include each file's place in the directory
tree. The long number in the second column of output is useful for
sorting. It tells the age of the file or directory in seconds. I sort
on it using "sort -k 2 -n". This means sort numerically based on the
second column.

Sorry, no color or file permissions or ownership.

-Joe
Eef Hartman
2018-08-05 06:53:19 UTC
Reply
Permalink
Raw Message
Post by Joe Rosevear
Directories are rather like files. They have creation dates and times.
Actually, no.
All files, including directories, have three dates:
last access (read)
last modification (contents)
last change (filename or I-node)
The last one is i.e. a "touch", change attributes, mv, etc. so not the
contents of the file itself, but the metadata about the file.

But NO creation date (the "cdate" is about changes and so DOES change.
Post by Joe Rosevear
I don't think a directory has a modification date or time, although
someone else might correct me. Even if it did, what would it mean?
Anything that modifies the directory, like removing or creating new
files IN it, changing names of files IN the directory.
The Real Bev
2018-08-05 14:54:10 UTC
Reply
Permalink
Raw Message
Post by Joe Rosevear
Post by The Real Bev
My go-to ls command is ls -altGF --color=yes |more. It does just what
I want with files, but directories stubbornly retain their creation
dates rather than the date on which a file contained therein was modified.
Is there any way to sort the way I want? I ask here because slackware
is frequently just DIFFERENT from the more popular distros.
Howdy,
The problem with your request is that it doesn't quite make sense.
Directories are rather like files. They have creation dates and times.
I don't think a directory has a modification date or time, although
someone else might correct me. Even if it did, what would it mean? A
directory is an entity that is independent of the files that are in it.
Files do have modification dates and times.
Would a list of all your files across sub-directories and sorted by
date and time help? Armed with such a list you could quickly determine
which directory contained the *file* with the oldest or youngest
modification.
Anyway, it was fun coming up with this, possibly not helpful, answer to
du . -a --time --time-style +%s\ %y%m%d\ %H:%M | sort -k 2 -n | less -R
du . -a --time --time-style +%s\ %y%m%d\ %H:%M | sort -k 2 -n | more
This is the du command, not ls. I chose du, because I knew it could
give me file listings that include each file's place in the directory
tree. The long number in the second column of output is useful for
sorting. It tells the age of the file or directory in seconds. I sort
on it using "sort -k 2 -n". This means sort numerically based on the
second column.
Sorry, no color or file permissions or ownership.
Color is just nice, and since I own everything 'ownership' is just a
nuisance.

Thanks. I made such a list a while back and then forgot how to do it.
I think I sorted by size in order to rid myself of useless files. Now
the method is saved forever!
--
Cheers, Bev
Nobody needs to speak on behalf of idiots, they manage
to speak entirely too much for themselves already.
Rich
2018-08-05 04:51:11 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
My go-to ls command is ls -altGF --color=yes |more. It does just what
I want with files, but directories stubbornly retain their creation
dates rather than the date on which a file contained therein was modified.
Well, the reason why is that the date shown for a directory is
independent of the dates shown for files therein, and that modifying a
file inside a directory (but not changing the filename) is not a
modification of the directory itself. So the modification time of the
directory is not changed in this situation.
Post by The Real Bev
Is there any way to sort the way I want?
You might get what you want for directories if you ask ls to use the
access time stamp instead of its default which is to use the
modification timestamp. That's the -u switch. But, it is an all or
nothing switch, so you'll also get the access time of files, which is
likely not the time you want to sort by for files. So short of
creating a custom ls for yourself, there may not be an easy way to get
what you want.
Post by The Real Bev
I ask here because slackware is frequently just DIFFERENT from the
more popular distros.
Nothing special here about Slackware. This is just how Unix
filesystems work. Modifying the file contents is not a modification of
the directory holding the filename.
The Real Bev
2018-08-05 14:55:22 UTC
Reply
Permalink
Raw Message
Post by Rich
Post by The Real Bev
My go-to ls command is ls -altGF --color=yes |more. It does just what
I want with files, but directories stubbornly retain their creation
dates rather than the date on which a file contained therein was modified.
Well, the reason why is that the date shown for a directory is
independent of the dates shown for files therein, and that modifying a
file inside a directory (but not changing the filename) is not a
modification of the directory itself. So the modification time of the
directory is not changed in this situation.
Post by The Real Bev
Is there any way to sort the way I want?
You might get what you want for directories if you ask ls to use the
access time stamp instead of its default which is to use the
modification timestamp. That's the -u switch. But, it is an all or
nothing switch, so you'll also get the access time of files, which is
likely not the time you want to sort by for files. So short of
creating a custom ls for yourself, there may not be an easy way to get
what you want.
Post by The Real Bev
I ask here because slackware is frequently just DIFFERENT from the
more popular distros.
Nothing special here about Slackware. This is just how Unix
filesystems work. Modifying the file contents is not a modification of
the directory holding the filename.
Well damn, it OUGHT to be! Thanks anyway!
--
Cheers, Bev
"Nothing in the universe can withstand the relentless application
of brute force and ignorance." -- Frd, via Dennis (evil)
Mike Spencer
2018-08-05 20:11:46 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
Post by Rich
Post by The Real Bev
My go-to ls command is ls -altGF --color=yes |more. It does just what
I want with files, but directories stubbornly retain their creation
dates rather than the date on which a file contained therein was modified.
Well, the reason why is that the date shown for a directory is
independent of the dates shown for files therein, and that modifying a
file inside a directory (but not changing the filename) is not a
modification of the directory itself. So the modification time of the
directory is not changed in this situation.
Post by The Real Bev
Is there any way to sort the way I want?
You might get what you want for directories if you ask ls to use the
access time stamp instead of its default which is to use the
modification timestamp. That's the -u switch. But, it is an all or
nothing switch, so you'll also get the access time of files, which is
likely not the time you want to sort by for files. So short of
creating a custom ls for yourself, there may not be an easy way to get
what you want.
Post by The Real Bev
I ask here because slackware is frequently just DIFFERENT from the
more popular distros.
Nothing special here about Slackware. This is just how Unix
filesystems work. Modifying the file contents is not a modification of
the directory holding the filename.
Well damn, it OUGHT to be! Thanks anyway!
I must be missing something here. I use Emacs DIRED mostly. If I
delete a file or edit (and save) a file in ~/gr/unpak at time t, DIRED
shows the timestamp of directory ~/gr to be updated to t. At command
line, ls -l also shows ~/gr with timestamp t. But this doesn't happen
if I merely touch(1) a file in ~/gr/unpak.

In Emacs, I routinely use M-x dired, then use s to sort the displayed
listing by date to bring the files most recently altered *and*
directories whose contents are most recently altered to the top of the
listing.

The Emacs variable dired-listing-switches, a string representing the
switches passed to the shell by Emacs with "ls", has value "-al".
--
Mike Spencer Nova Scotia, Canada
Richard Kettlewell
2018-08-05 20:19:05 UTC
Reply
Permalink
Raw Message
Post by Mike Spencer
I must be missing something here. I use Emacs DIRED mostly. If I
delete a file or edit (and save) a file in ~/gr/unpak at time t, DIRED
shows the timestamp of directory ~/gr to be updated to t. At command
line, ls -l also shows ~/gr with timestamp t. But this doesn't happen
if I merely touch(1) a file in ~/gr/unpak.
In Emacs, I routinely use M-x dired, then use s to sort the displayed
listing by date to bring the files most recently altered *and*
directories whose contents are most recently altered to the top of the
listing.
Modifying a file, in place, doesn’t modify the containing directory, and
therefore does not update its last modification time. So a directory’s
modification time can be older than the last time a file within it was
modified.

But applications may modify a file by creating a temporary file and
renaming it over the new one, and/or they may create a backup file in
the same directory, both of which will modify that directory at the same
time as modifying the file. The behaviour you are seeing is probably the
result of one of these effects.
--
https://www.greenend.org.uk/rjk/
Rich
2018-08-05 21:13:24 UTC
Reply
Permalink
Raw Message
Post by Mike Spencer
I must be missing something here. I use Emacs DIRED mostly. If I
delete a file
Deleting a file is a change to the directory containing the link (the
filename) to the file, so the directory mod-time stamp is updated.
Post by Mike Spencer
or edit (and save) a file in ~/gr/unpak at time t, DIRED
shows the timestamp of directory ~/gr to be updated to t.
Emacs is likely performing a save by writing a new temporary file, then
renaming that new temp file overtop of the old existing file, which
counts as two modifications to the directory containing both links.
Post by Mike Spencer
line, ls -l also shows ~/gr with timestamp t. But this doesn't happen
if I merely touch(1) a file in ~/gr/unpak.
Touching of a file simply changes the mod-time stamp stored in the
inode of the file, but does not make any changes to the directory
containing the link (the filename) to the file.
Eef Hartman
2018-08-05 21:23:51 UTC
Reply
Permalink
Raw Message
Post by Mike Spencer
I must be missing something here. I use Emacs DIRED mostly.
Most editors don't change the file itself but create a new, temporary,
file first and then rename it back to the original filename when you
save and exit. So that is a directory change (twice), the creation and
the rename.
Eef Hartman
2018-08-05 07:04:53 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
Is there any way to sort the way I want? I ask here because slackware
is frequently just DIFFERENT from the more popular distros.
The filesystem, and thus the way dates are stored, is standard for all
Unix derived O/S'es, including Slackware. It is in the kernel (modules
for the filesystem).

BTW: this alias will make the modification date OF current dir the
same as the newest file IN it:
touch -r "`/bin/ls -ALt|head -1`" .
(the A is to exclude the . and .. entries themselves, the L follows
symbolic links so it doesn't use the date of the link itself).
The Real Bev
2018-08-05 14:55:30 UTC
Reply
Permalink
Raw Message
Post by Eef Hartman
Post by The Real Bev
Is there any way to sort the way I want? I ask here because slackware
is frequently just DIFFERENT from the more popular distros.
The filesystem, and thus the way dates are stored, is standard for all
Unix derived O/S'es, including Slackware. It is in the kernel (modules
for the filesystem).
Did DOS or an older version of windows (95 is the last one I used
regularly) do what I want? Or maybe even win7, which I use only
sporadically and not enough to care much about stuff I normally regard
as important?
Post by Eef Hartman
BTW: this alias will make the modification date OF current dir the
touch -r "`/bin/ls -ALt|head -1`" .
(the A is to exclude the . and .. entries themselves, the L follows
symbolic links so it doesn't use the date of the link itself).
Thanks. This is good if I forget to touch the directory after I finish
editing.
--
Cheers, Bev
"Nothing in the universe can withstand the relentless application
of brute force and ignorance." -- Frd, via Dennis (evil)
Henrik Carlqvist
2018-08-05 17:53:10 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
Did DOS or an older version of windows (95 is the last one I used
regularly) do what I want?
It was about the same version I also used last at home, upgraded from
Windows 3.11 to 95 but decided that 95 was crap and switched to Slackware
instead. However, I did use DOS and Windows quite a lot back then.

If I remember right DOS/Windows only has one timestamp in the file system
for each file or directory. Also, if I remember right the timestamp of a
directory is not updated in DOS if somthing happens in a directory so
maybe DOS by default behaved exactly like what you now want.

The easiest way to get a DOS prompt in linux is to type "wine
cmd" (assuming that you have wine installed). But even with such a DOS
prompt time stamps will behave the Linux way, probably because of the
underlying file system, possibly because of the wine implementation...

regards Henrik
The Real Bev
2018-08-05 19:01:56 UTC
Reply
Permalink
Raw Message
Post by Henrik Carlqvist
Post by The Real Bev
Did DOS or an older version of windows (95 is the last one I used
regularly) do what I want?
It was about the same version I also used last at home, upgraded from
Windows 3.11 to 95 but decided that 95 was crap and switched to Slackware
instead. However, I did use DOS and Windows quite a lot back then.
I was pretty happy with 95. I had lots of useful applications and I
even felt comfy editing the registry. New computer, couldn't transfer
blablablabla. I really got sick of starting from scratch (and losing a
lot of utility) every time a new version came out (just like mozilla
stuff, but I'm still loyal!) and I'm NOT updating the winmachine from
win7 unless I have to to run tax software :-(
Post by Henrik Carlqvist
If I remember right DOS/Windows only has one timestamp in the file system
for each file or directory. Also, if I remember right the timestamp of a
directory is not updated in DOS if somthing happens in a directory so
maybe DOS by default behaved exactly like what you now want.
Hard to believe that 95 was 23 years ago :-(
Post by Henrik Carlqvist
The easiest way to get a DOS prompt in linux is to type "wine
cmd" (assuming that you have wine installed). But even with such a DOS
prompt time stamps will behave the Linux way, probably because of the
underlying file system, possibly because of the wine implementation...
That's a LOT more trouble than it's worth :-( I think I have two wines,
maybe more. The one that comes with slackware, the one that comes with
google earth, and maybe one that comes with another google product.
Maybe picasa. If it ain't broke...

Date order is SOOOO much more important than filenames. I don't see how
people can stand the simple execution of ls :-(
--
Cheers, Bev
Not all cultures are equal. If they were, we
would have a lot more cannibal restaurants.
Rich
2018-08-05 20:06:06 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
Date order is SOOOO much more important than filenames. I don't see
how people can stand the simple execution of ls :-(
To each his own. When I'm looking for a file, I want filename order
(which is the default). I very seldom ever want mod-date ordering, but
when I do, the -t switch is there. And for the times I want an
enforced date order (archived statements, etc) I begin the filename
with the date of the statement, i.e., "2018-08-05-bank-statement.pdf"
in which case the filename sort order of 'ls' becomes a "date sort" at
the same time.
Henrik Carlqvist
2018-08-06 05:34:57 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
Post by Henrik Carlqvist
It was about the same version I also used last at home, upgraded from
Windows 3.11 to 95 but decided that 95 was crap and switched to
Slackware instead. However, I did use DOS and Windows quite a lot back
then.
I was pretty happy with 95. I had lots of useful applications and I
even felt comfy editing the registry.
I used to dual boot between DOS/Windows and Slackware Linux. Both
operating systems were mounting the FAT partition called C: in
DOS/Windows. Everything worked great until I added Windows 95 to the mix.
I could then at boot choos to load Windows 3.11, Windows 95 or Slackware
Linux. It turned out that Windows 95 with its VFAT made one of my most
important utilities in Windows 3.11 unusable. If I remember right it was
some kind of Norton Defrag utility.

So I found that Slackware Linux was more compatible with Microsoft
Windows 3.11 than Microsofts own Windows 95. Eventually I stopped dual
booting and only ran Slackware Linux.

regards Henrik
The Real Bev
2018-08-06 06:39:32 UTC
Reply
Permalink
Raw Message
Post by Henrik Carlqvist
Post by The Real Bev
Post by Henrik Carlqvist
It was about the same version I also used last at home, upgraded from
Windows 3.11 to 95 but decided that 95 was crap and switched to
Slackware instead. However, I did use DOS and Windows quite a lot back
then.
I was pretty happy with 95. I had lots of useful applications and I
even felt comfy editing the registry.
I used to dual boot between DOS/Windows and Slackware Linux. Both
operating systems were mounting the FAT partition called C: in
DOS/Windows. Everything worked great until I added Windows 95 to the mix.
I could then at boot choos to load Windows 3.11, Windows 95 or Slackware
Linux. It turned out that Windows 95 with its VFAT made one of my most
important utilities in Windows 3.11 unusable. If I remember right it was
some kind of Norton Defrag utility.
I never liked Norton. He grabbed public domain stuff and slapped his
name on it.
Post by Henrik Carlqvist
So I found that Slackware Linux was more compatible with Microsoft
Windows 3.11 than Microsofts own Windows 95. Eventually I stopped dual
booting and only ran Slackware Linux.
I started using linux with a dialup shell account in 1994. Not certain
when I converted to using it on my own machine, but it was maybe a
couple of years later. "Use the distro that your Consultant uses..."
Everybody has two machines and a kvm switch, right?
--
Cheers, Bev
You know it's time to clean the refrigerator when
something closes the door from the inside.
Michael Black
2018-08-06 14:49:13 UTC
Reply
Permalink
Raw Message
Post by Henrik Carlqvist
Post by The Real Bev
Post by Henrik Carlqvist
It was about the same version I also used last at home, upgraded from
Windows 3.11 to 95 but decided that 95 was crap and switched to
Slackware instead. However, I did use DOS and Windows quite a lot back
then.
I was pretty happy with 95. I had lots of useful applications and I
even felt comfy editing the registry.
I used to dual boot between DOS/Windows and Slackware Linux. Both
operating systems were mounting the FAT partition called C: in
DOS/Windows. Everything worked great until I added Windows 95 to the mix.
I could then at boot choos to load Windows 3.11, Windows 95 or Slackware
Linux. It turned out that Windows 95 with its VFAT made one of my most
important utilities in Windows 3.11 unusable. If I remember right it was
some kind of Norton Defrag utility.
I never liked Norton. He grabbed public domain stuff and slapped his name
on it.
Post by Henrik Carlqvist
So I found that Slackware Linux was more compatible with Microsoft
Windows 3.11 than Microsofts own Windows 95. Eventually I stopped dual
booting and only ran Slackware Linux.
I started using linux with a dialup shell account in 1994. Not certain when
I converted to using it on my own machine, but it was maybe a couple of years
later. "Use the distro that your Consultant uses..." Everybody has two
machines and a kvm switch, right?
That sounds like a quote from Jerry Pournelle.

Michael
The Real Bev
2018-08-06 16:47:08 UTC
Reply
Permalink
Raw Message
Post by Michael Black
Post by Henrik Carlqvist
Post by The Real Bev
Post by Henrik Carlqvist
It was about the same version I also used last at home, upgraded from
Windows 3.11 to 95 but decided that 95 was crap and switched to
Slackware instead. However, I did use DOS and Windows quite a lot back
then.
I was pretty happy with 95. I had lots of useful applications and I
even felt comfy editing the registry.
I used to dual boot between DOS/Windows and Slackware Linux. Both
operating systems were mounting the FAT partition called C: in
DOS/Windows. Everything worked great until I added Windows 95 to the mix.
I could then at boot choos to load Windows 3.11, Windows 95 or Slackware
Linux. It turned out that Windows 95 with its VFAT made one of my most
important utilities in Windows 3.11 unusable. If I remember right it was
some kind of Norton Defrag utility.
I never liked Norton. He grabbed public domain stuff and slapped his name
on it.
Post by Henrik Carlqvist
So I found that Slackware Linux was more compatible with Microsoft
Windows 3.11 than Microsofts own Windows 95. Eventually I stopped dual
booting and only ran Slackware Linux.
I started using linux with a dialup shell account in 1994. Not certain when
I converted to using it on my own machine, but it was maybe a couple of years
later. "Use the distro that your Consultant uses..." Everybody has two
machines and a kvm switch, right?
That sounds like a quote from Jerry Pournelle.
From somebody, and it's good advice!
--
Cheers, Bev
"I love this country...
...and the freedoms we used to have..."
--George Carlin
Ivan Shmakov
2018-08-10 17:25:51 UTC
Reply
Permalink
Raw Message
[...]
Post by Henrik Carlqvist
If I remember right DOS/Windows only has one timestamp in the file
system for each file or directory.
For some reason, I was sure that filesystems of the FAT family
supported also "creation time." However, per the respective
Wikipedia article [1] this appears to be a "DOS 7" addition,
and ECMA 107 [2] doesn't seem to mention anything relevant but
"date recorded" and "time recorded" directory entry fields (below.)

11.3.5 Time Recorded (BP 23 and 24)

This field shall contain a 16-bit integer representing a time.
The time shall be expressed in terms of hour (0 to 23), minute
(0 to 59), and second (0 to 59). The value of this integer
shall be computed by the formula:

(2048 x hour) + (32 x minute) + ip (second / 2)

The value shall be recorded as a numerical value according to 8.2.

11.3.6 Date Recorded (BP 25 and 26)

This field shall contain a 16-bit integer representing a date.
The date shall be expressed in terms of year (1980 to 2107),
month (1 to 12), and day (1 to 31). [...]

[1] http://en.wikipedia.org/wiki/Design_of_the_FAT_file_system
[2] http://ecma-international.org/publications/files/ECMA-ST/Ecma-107.pdf

[...]
--
FSF associate member #7257 np. All Along the Watchtower -- Jimi Hendrix
Eef Hartman
2018-08-05 18:57:14 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
Did DOS or an older version of windows (95 is the last one I used
regularly) do what I want?
DOS never changed the directory creation date, whatever happened IN
that directory. Not even when you create new files IN the directory
did its date change.
I'm not quite sure when the "extra" timestamps were introduced in
Windows, I never really used any Windows 9x or later, but the original
MS-Dos (and thus Windows 3.xx too) only had a single date/time for
every file and/or directory (which for directories was the creation
date/time).
King Beowulf
2018-08-06 21:13:50 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
My go-to ls command is ls -altGF --color=yes |more. It does just what
I want with files, but directories stubbornly retain their creation
dates rather than the date on which a file contained therein was modified.
Is there any way to sort the way I want? I ask here because slackware
is frequently just DIFFERENT from the more popular distros.
I just applied your 'ls' on my $HOME since it sounded nifty, It has a
variety of files and junk with a variety of creation and modification
dates.

Slackware64 14.2 multilib
Xfce
full install July 2016
ext4
$HOME on separate drive/partition and kept as-is from 14.0->14.1->14.2
(except for cleaning out DE kruft and obsolete files)

I get a listing where both files and directories are sorted by last
modification date in linux console, xfce-terminal and xterm.

All files are sorted correctly by modification date, however directories
are a bit trickier:

Directory modification date changes when:
1. files are added or deleted
2. rm file and then recreate with same file name
3. copying/moving a file with the same name
4. linking/unlinking files or directories

If an existing file is simply changed/edited but not removed, the
directory is not modified. This is teh expected behavior for ext2/3/4
file systems.

As mentioned previously in this thread, Slackware is not 'different' and
obeys the same Linux/Unix file system rules as any other distribution.

If want a sorted list of directories whose *files* where modified, use
'find' for example:

find [dir-to-search] -type f -mtime -1 -maxdepth 2 -exec dirname {} \; |
sort --unique

('maxdepth 2' limits to current dir and not subdirs).
The Real Bev
2018-08-07 04:12:42 UTC
Reply
Permalink
Raw Message
Post by King Beowulf
Post by The Real Bev
My go-to ls command is ls -altGF --color=yes |more. It does just what
I want with files, but directories stubbornly retain their creation
dates rather than the date on which a file contained therein was modified.
Is there any way to sort the way I want? I ask here because slackware
is frequently just DIFFERENT from the more popular distros.
I just applied your 'ls' on my $HOME since it sounded nifty, It has a
variety of files and junk with a variety of creation and modification
dates.
Slackware64 14.2 multilib
Xfce
full install July 2016
ext4
$HOME on separate drive/partition and kept as-is from 14.0->14.1->14.2
(except for cleaning out DE kruft and obsolete files)
I get a listing where both files and directories are sorted by last
modification date in linux console, xfce-terminal and xterm.
All files are sorted correctly by modification date, however directories
1. files are added or deleted
2. rm file and then recreate with same file name
3. copying/moving a file with the same name
4. linking/unlinking files or directories
If an existing file is simply changed/edited but not removed, the
directory is not modified. This is teh expected behavior for ext2/3/4
file systems.
As mentioned previously in this thread, Slackware is not 'different' and
obeys the same Linux/Unix file system rules as any other distribution.
If want a sorted list of directories whose *files* where modified, use
find [dir-to-search] -type f -mtime -1 -maxdepth 2 -exec dirname {} \; |
sort --unique
('maxdepth 2' limits to current dir and not subdirs).
That seems kind of cumbersome for casual use.

What I should do is just make a couple of aliases -- t for 'touch crap'
and d for 'rm -f crap' -- and use them as needed whenever I edit
anything in a subdirectory. I usually use a small number of
directories, so it shouldn't be too painful. Crude, of course, but
better than nothing.
--
Cheers, Bev
If I know that chaining yourself to a dead cow is stupid,
how come Carly makes so much more money than I do?
Rich
2018-08-07 11:26:37 UTC
Reply
Permalink
Raw Message
Post by The Real Bev
Post by King Beowulf
find [dir-to-search] -type f -mtime -1 -maxdepth 2 -exec dirname {} \; |
sort --unique
('maxdepth 2' limits to current dir and not subdirs).
That seems kind of cumbersome for casual use.
Which is why you'd wrap it into an aliais or shell script file for
casual use.
Post by The Real Bev
What I should do is just make a couple of aliases -- t for 'touch
crap' and d for 'rm -f crap' -- and use them as needed whenever I
edit anything in a subdirectory.
You don't need to create and delete a file to update the current dir's
timestamp. "touch ." (the . entry represents the current directory you
are in) will update the timestamp of the current directory.
Post by The Real Bev
I usually use a small number of directories, so it shouldn't be too
painful. Crude, of course, but better than nothing.
You can also use find, along with a small helper script, to scan your
hierarchy of directories and automatically touch each one with the
newest date of a containing file to create the situation you want.

Then you either run it manually to update the directory timestamps, or
you setup a cron job to launch it periodically to update all the
directory timestamps.

I.e., you'd put this into a file named "touch-dir" (note this is Bash
and GNU xargs specific):

---cut---cut---cut---cut---
#!/bin/bash

for dir in "$@" ; do

DDATE=$(find "$dir" -type f -maxdepth 1 -print0 \
| xargs -0 --no-run-if-empty stat --format=%y \
| sort -r \
| uniq \
| head -1)

if [[ ${#DDATE} -gt 0 ]] ; then
touch --date="$DDATE" "$dir"
fi

done
---cut---cut---cut---cut---

Next you would make "touch-dir" executable and put it into your ~/bin
which is on your PATH search list (what, you don't have a ~/bin
directory that is on your PATH, well, then make one and configure it to
be on your PATH).

Next you'd create another script file, named say
"update-dir-timestamps" and put this into it:

---cut---cut---cut---cut---
#!/bin/bash

find ~ -type d -xdev -print0 | xargs -0 touch-dir
---cut---cut---cut---cut---

You'd then make that executable and also put it into your ~/bin
directory.

You'd also replace ~ with the top of the directory heirarchy you want
to update (or leave ~ if you want to do your whole home directory).

Then anytime you want all the dir timestamps to match the oldest file
inside, run "update-dir-timestamps" and all of them will be updated to
match the oldest file inside.

If you want it to run automatically, then add it to your local crontab
to run on a periodioc basis.
The Real Bev
2018-08-08 04:03:56 UTC
Reply
Permalink
Raw Message
Post by Rich
Post by The Real Bev
Post by King Beowulf
find [dir-to-search] -type f -mtime -1 -maxdepth 2 -exec dirname {} \; |
sort --unique
('maxdepth 2' limits to current dir and not subdirs).
That seems kind of cumbersome for casual use.
Which is why you'd wrap it into an aliais or shell script file for
casual use.
Post by The Real Bev
What I should do is just make a couple of aliases -- t for 'touch
crap' and d for 'rm -f crap' -- and use them as needed whenever I
edit anything in a subdirectory.
You don't need to create and delete a file to update the current dir's
timestamp. "touch ." (the . entry represents the current directory you
are in) will update the timestamp of the current directory.
Post by The Real Bev
I usually use a small number of directories, so it shouldn't be too
painful. Crude, of course, but better than nothing.
You can also use find, along with a small helper script, to scan your
hierarchy of directories and automatically touch each one with the
newest date of a containing file to create the situation you want.
Then you either run it manually to update the directory timestamps, or
you setup a cron job to launch it periodically to update all the
directory timestamps.
I.e., you'd put this into a file named "touch-dir" (note this is Bash
---cut---cut---cut---cut---
#!/bin/bash
DDATE=$(find "$dir" -type f -maxdepth 1 -print0 \
| xargs -0 --no-run-if-empty stat --format=%y \
| sort -r \
| uniq \
| head -1)
if [[ ${#DDATE} -gt 0 ]] ; then
touch --date="$DDATE" "$dir"
fi
done
---cut---cut---cut---cut---
Next you would make "touch-dir" executable and put it into your ~/bin
which is on your PATH search list (what, you don't have a ~/bin
directory that is on your PATH, well, then make one and configure it to
be on your PATH).
Next you'd create another script file, named say
---cut---cut---cut---cut---
#!/bin/bash
find ~ -type d -xdev -print0 | xargs -0 touch-dir
---cut---cut---cut---cut---
You'd then make that executable and also put it into your ~/bin
directory.
You'd also replace ~ with the top of the directory heirarchy you want
to update (or leave ~ if you want to do your whole home directory).
Then anytime you want all the dir timestamps to match the oldest file
inside, run "update-dir-timestamps" and all of them will be updated to
match the oldest file inside.
If you want it to run automatically, then add it to your local crontab
to run on a periodioc basis.
This looks REALLY promising, thanks!
--
Cheers, Bev
"We thought about one of those discount store caskets, but,
frankly, we were worried about the quality."
-- mortuary commercial
Ivan Shmakov
2018-08-07 13:17:45 UTC
Reply
Permalink
Raw Message
[...]
Post by King Beowulf
If want a sorted list of directories whose *files* where modified,
find [dir-to-search] -type f -mtime -1 -maxdepth 2 \
-exec dirname {} \; | sort --unique
('maxdepth 2' limits to current dir and not subdirs).
And it should be used before all the other criteria so to avoid
a warning from certain find(1) versions. Moreover:

* a call to dirname(1) can easily be avoided, as find(1) has
-printf "%h" directive;

* there's no need to do a sort(1), as the output is ought to
already be suitable for uniq(1).

Thus:

$ find DIRECTORY... -maxdepth 2 -type f -mtime -1 -printf %h\\n | uniq
--
FSF associate member #7257 http://am-1.org/~ivan/
Eli the Bearded
2018-08-07 22:06:02 UTC
Reply
Permalink
Raw Message
Post by Ivan Shmakov
Post by King Beowulf
If want a sorted list of directories whose *files* where modified,
And it should be used before all the other criteria so to avoid
* a call to dirname(1) can easily be avoided, as find(1) has
-printf "%h" directive;
Good call.
Post by Ivan Shmakov
* there's no need to do a sort(1), as the output is ought to
already be suitable for uniq(1).
Are you sure?
Post by Ivan Shmakov
$ find DIRECTORY... -maxdepth 2 -type f -mtime -1 -printf %h\\n | uniq
$ find ~ -maxdepth 2 -type f -mtime -1 -printf %h\\n | uniq
/home/username
/home/username/bin
/home/username
/home/username/firefox
/home/username/tmp
/home/username
$

Seems I have some history files in ~ that get updated often. Things like
shell history, .viminfo, .lesshst.

Elijah
------
found on first try
Ivan Shmakov
2018-08-08 00:48:27 UTC
Reply
Permalink
Raw Message
[...]
Post by Eli the Bearded
* there's no need to do a sort(1), as the output is ought to already
be suitable for uniq(1).
Are you sure?
Indeed, I've confused that with -maxdepth 2 -mindepth 2 (or any
other given depth.)
Post by Eli the Bearded
$ find DIRECTORY... -maxdepth 2 -type f -mtime -1 -printf %h\\n | uniq
$ find ~ -maxdepth 2 -type f -mtime -1 -printf %h\\n | uniq
/home/username
/home/username/bin
/home/username
/home/username/firefox
/home/username/tmp
/home/username
$
Still no need to do a full sort (although now that I think of
it, it may be beneficial regardless); consider, e. g.:

$ find DIRECTORY... -maxdepth 2 -type f -mtime -1 \
-printf %h\\n | awk '! seen_p[$0] { print $0; seen_p[$0] = 1; }'

In my book of snippets, I have also the following Awk code,
similar in effect to sort | uniq -c, except for preserving the
order of (non-duplicate) input lines.

gawk '1 { if (seen[$0]++ <= 0) { ord[count++] = $0; } }
END { for (i = 0; i < count; i++) { print seen[ord[i]] "\t" ord[i]; } }'
Post by Eli the Bearded
Seems I have some history files in ~ that get updated often. Things
like shell history, .viminfo, .lesshst.
FWIW, I've found .lesshst a somewhat useless addition and have
export LESSHISTFILE=/dev/null in my ~/.bash_profile (or, rather,
~/.session_common, sourced from both there and ~/.xsession.)
--
FSF associate member #7257 http://am-1.org/~ivan/
Eli the Bearded
2018-08-08 23:04:12 UTC
Reply
Permalink
Raw Message
Post by Ivan Shmakov
FWIW, I've found .lesshst a somewhat useless addition and have
export LESSHISTFILE=/dev/null in my ~/.bash_profile (or, rather,
~/.session_common, sourced from both there and ~/.xsession.)
I would agree that .lesshst is useless. I use far too many systems
during the course of a day to worry about that. It's far more of a
concern to me that typical Linux systems include an /etc/bashrc that
will change my window titles when I log into a system but provide no
method for changing them back.

for host in $(seq -w 01 24); do
ssh system-$host.site.name
# do stuff
done

Presumably because they assume you'll be using that same system
everywhere, whereas I don't even use bash, much less the xterm title
changing PROMPT_COMMAND /etc/bashrc provides, from my "home" system.

Now you might say "SSHing into a bunch of systems to do somethine sounds
like a process that should be automated." You'd be right. In this
network of systems, there is Ansible for that. My recent work has been
getting a long neglected Ansible system back to working order.

And it turns out that Ansible's `ansible-playbook` tool breaks my old
fix for this title change stuff because it starts a subshell that passes
the "it's interactive" test (`case "$-" in *i*)`) which runs the title
setting code for my shell.

Ansible uses that shell to run ssh, but apparently doesn't set the
remote terminal to "xterm", so the remote side doesn't run it's title
change stuff, but the title change from my side shows up in the stream
and breaks things. And in the standard configuration, Ansible isn't
setting any environment variables that let me test "is running in
Ansible", nor does it clear the TERM environment variable.

I've been contemplating using a personal Ansible config here send out a
complete set of dot files to every system, but then I'd still need to
worry about the new ones not yet Ansibilized.

Elijah
------
doesn't mind the hostname in window title, but wants it changed back
Eef Hartman
2018-08-09 06:11:47 UTC
Reply
Permalink
Raw Message
Post by Eli the Bearded
doesn't mind the hostname in window title, but wants it changed back
I use "xtermcontrol --title" for that.
Note that I do not use bash for interactive shells so the
PROMPT_COMMAND setting does not override this for me.

Remote shells are started with commands like:
xterm -title DelRey -e ssh delrey
(needs authorized by public key access on the remote system)

xtermcontrol can be gotten from
thrysoee.dk/xtermcontrol
it's easy to compile. The one in slackbuilds.org is outdated (and only
available for Slackware 12.2).
Eli the Bearded
2018-08-09 19:07:12 UTC
Reply
Permalink
Raw Message
Post by Eef Hartman
I use "xtermcontrol --title" for that.
I know how to manually fix it, it's just annoying and I was ranting.
Post by Eef Hartman
Note that I do not use bash for interactive shells so the
PROMPT_COMMAND setting does not override this for me.
This is $WORK, so I don't have the option of having preconfigured all of
the machines to have the system the way I want it with the shell I'd
prefer to use installed. I'm not even sure if/where I can change the
default shell in this all-accounts-come-from-ldap configuration.
Post by Eef Hartman
xterm -title DelRey -e ssh delrey
(needs authorized by public key access on the remote system)
There are hundreds of hosts here. Rather than creating and deleting
local accounts every time there is a staffing change, it all goes in the
LDAP server. The systems are configured during initial install with a
single root account that can be used to install the System Security
Services Daemon (sssd) and PAM config for sss to reach the LDAP server
for accounts. Then on initial login oddjobd creates the user home
directory from the standard skeleton files. Nothing in that local
configuration defines things usually found in /etc/passwd, /etc/group,
or /etc/shadow for normal users. All of that comes out of LDAP.

I'm building new servers and fixing old ones, but I'm not admining LDAP.

Elijah
------
only knows a smidgen of LDAP anyway
Henrik Carlqvist
2018-08-10 06:05:40 UTC
Reply
Permalink
Raw Message
Post by Eli the Bearded
I'm not even sure if/where I can change the
default shell in this all-accounts-come-from-ldap configuration.
As a normal user you will att least most likely be able to edit your
login scripts. If you in your login script write something like:

exec /bin/my_favorite_shell

Your user will use another shell than the one provided by the used passwd
mechanism. However, in a corporate environment they usually do not only
provide a shell but also standardized login scripts setting things like
alisases and different pathts. If you change shell you might lose some of
those settings unless you also add them yourself to the login scripts
used by your favorite shell.

It might also be worth noting that when you start a command line terminal
application in a graphical environment your login scripts will not be run
unless the terminal is started as a login shell. For xterm that could be
done by adding the flag "-ls" or adding the line

*loginShell: True

to your .Xresources if that file is used by xrdb from your X startup
scripts. For most other terminal emulaturs you will need to point and
click among graphical configuration menus.

regards Henrik
Eef Hartman
2018-08-10 06:29:59 UTC
Reply
Permalink
Raw Message
Post by Henrik Carlqvist
As a normal user you will att least most likely be able to edit your
exec /bin/my_favorite_shell
Better test if it's available on the remote system:
test -x /bin/my_favorite_shell && exec /bin/my_favorite_shell
Ivan Shmakov
2018-08-10 06:42:36 UTC
Reply
Permalink
Raw Message
Post by Henrik Carlqvist
As a normal user you will att least most likely be able to edit your
exec /bin/my_favorite_shell
Better test if it's available on the remote system: test -x
/bin/my_favorite_shell && exec /bin/my_favorite_shell
Is it any better than the following?

exec /bin/my_favorite_shell || : ignore possible failure
--
FSF associate member #7257 http://am-1.org/~ivan/
Eef Hartman
2018-08-10 07:04:46 UTC
Reply
Permalink
Raw Message
Post by Ivan Shmakov
Is it any better than the following?
exec /bin/my_favorite_shell || : ignore possible failure
The _real_ condition I used are even more complicated as to avoid
doing a shell change for _scripts_ and other non-interactive shells
on the remote system:

if tty -s # do we have stdin on a terminal?
then if [ "$TERM" ] # is TERM set?
then termtype=`echo $TERM | cut -c1-2`
if [ $termtype = co -o $TERM = linux -o $termtype = vt -o $TERM = xterm ]
then test -x /bin/tcsh && exec /bin/tcsh
# this won't be reached when tcsh is there
# settings for bash
fi
fi
fi

but, of course, now I do not need it anymore, my login shell has been
set to tcsh. The above code is from the root account, to make sure it
will always get an existing shell.

Essential the above code will work in bash and dash, which in some
systems is the "/bin/sh" shell.
Richard Kettlewell
2018-08-10 07:37:44 UTC
Reply
Permalink
Raw Message
Post by Ivan Shmakov
Post by Henrik Carlqvist
As a normal user you will att least most likely be able to edit your
exec /bin/my_favorite_shell
Better test if it's available on the remote system: test -x
/bin/my_favorite_shell && exec /bin/my_favorite_shell
Is it any better than the following?
exec /bin/my_favorite_shell || : ignore possible failure
Depends on your version of ‘better’. The first and last will display an
error message if the shell can’t be executed, the middle one will not.
Otherwise I don’t think there’s much to choose between them.
--
https://www.greenend.org.uk/rjk/
Eef Hartman
2018-08-10 06:47:43 UTC
Reply
Permalink
Raw Message
Post by Eli the Bearded
I'm not even sure if/where I can change the
default shell in this all-accounts-come-from-ldap configuration.
If it's correctly wrapped for yp/ldap usage, chsh should do it.

In my "previous enployment" we used ldap too, against a central Active
Directory Server (which is about the same thing, but then in
MS-Windows). But in our case the home directory was centralized too,
on a Linux formatted (NFS capable) NAS server, as to provide one
consistent home environment for all Linux users (they had a Windows
home dir too, which wasn't auto-mounted for Linux, on a DFS (Distributed
File System) cluster of servers).
Post by Eli the Bearded
There are hundreds of hosts here. Rather than creating and deleting
local accounts every time there is a staffing change, it all goes in the
LDAP server.
Same with us, it even had a central login name that was used both for
Linux and Windows usage. And as it had the shared home dir, we only
had to add the public key of "your own workstation" to the
ssh/authorized_keys
file to enabled password-less ssh to all machines that shared that
home directory.
Of course the Linux image was customized too, first openSUSE and later
(as its support time was too short) SLED, with all the LDAP etc.
support the image needed built-in.
So you _could_ change your password etc from the client workstation
and with LDAP you could also query your current settings from the ADS
server.
Ivan Shmakov
2018-08-09 18:50:50 UTC
Reply
Permalink
Raw Message
Post by Ivan Shmakov
FWIW, I've found .lesshst a somewhat useless addition and have
export LESSHISTFILE=/dev/null in my ~/.bash_profile (or, rather,
~/.session_common, sourced from both there and ~/.xsession.)
I would agree that .lesshst is useless. I use far too many systems
during the course of a day to worry about that. It's far more of a
concern to me that typical Linux systems include an /etc/bashrc that
will change my window titles when I log into a system but provide no
method for changing them back.
This looks like a reason to set XTerm*vt100.allowTitleOps to
"false". There's even a way to change it at run-time (e. g.,
via editres(1)), but I'm unsure if it's readily possible to do
it from shell code.

Personally, I use Screen under XTerm, configured so that it will
use window's title as its hardstatus, which then becomes Screen
own hardstatus, which is XTerm window title.

defhstatus "^Et"
hardstatus string "%0c --- %3n. %h"
for host in $(seq -w 01 24); do ssh system-$host.site.name # do stuff
done
For non-interactive use, I've found dsh(1) quite useful. E. g.:

$ LC_ALL=C dsh -cM --group=@myhosts -o-n -- df -- /var

And for an interactive loop like the above, I'd use a dedicated
Screen window, thus its title will be irrelevant for my "local"
interaction.

[...]
I've been contemplating using a personal Ansible config here send out
a complete set of dot files to every system, but then I'd still need
to worry about the new ones not yet Ansibilized.
FWIW, I use Rsync to distribute my dotfiles and other useful
bits across my multiple $HOME directories.

$ cat < private/rsync/common-upload-private.filter
### common-upload-private.filter -*- Default-Generic -*-
- .rsync-backup
- .backup/
- *~
- [,+]*.????????
+ .bash_logout
+ .bash_profile
+ .bashrc
+ .cpan/
+ .emacs
+ .gitconfig
## ...
+ elisp/
+ elisp/minemacs.el
+ private/
+ private/rsync/
+ private/rsync/backup-private.filter
+ tmp/
## Exclude the rest
- *
### common-upload-private.filter ends here
$ rsync -uvb -rOtH --suffix=.~$(date +%s)~ \
--backup-dir=.rsync-backup --exclude=.rsync-backup \
--exclude=\*~ --exclude-from=private/rsync/common-upload-private.filter \
--exclude=\* -- ~/ remote:
--
FSF associate member #7257 np. Coming Home -- Iron Maiden
Eli the Bearded
2018-08-09 19:55:37 UTC
Reply
Permalink
Raw Message
Post by Ivan Shmakov
This looks like a reason to set XTerm*vt100.allowTitleOps to
"false". There's even a way to change it at run-time (e. g.,
via editres(1)), but I'm unsure if it's readily possible to do
it from shell code.
Well, I'm fine with having the title change to show that I'm logged in
to a remote system, I just want it changed back. (And I don't want my
shell prompt doing the changing.) This apparently is a minority opinion.
Post by Ivan Shmakov
Personally, I use Screen under XTerm, configured so that it will
I use tmux these days, it's roughly the same, but a cleaner codebase and
supposedly better with UTF-8. I don't use it for every single xterm
though.
Since I don't have passwordless logins configured, I use sshpass in a
loop with ssh for that sort of thing. (This is basically what Ansible
does behind the scenes.[*])
Post by Ivan Shmakov
FWIW, I use Rsync to distribute my dotfiles and other useful
bits across my multiple $HOME directories.
See above issue with passwords.

Elijah
------
[*] What ansible actually does behind the scenes is sshpass to run ssh
to run python on the remote end feeding a script in on stdin which
contains the script to run as a base64 zip file inside it; remote
python forks a child to unzip the contents to a local temp directory
and then forks another child to run that script. (And that's the
high level view.)
Ivan Shmakov
2018-08-10 06:24:36 UTC
Reply
Permalink
Raw Message
Post by Eli the Bearded
Post by Ivan Shmakov
This looks like a reason to set XTerm*vt100.allowTitleOps to
"false". There's even a way to change it at run-time (e. g., via
editres(1)), but I'm unsure if it's readily possible to do it from
shell code.
Well, I'm fine with having the title change to show that I'm logged
in to a remote system, I just want it changed back. (And I don't
want my shell prompt doing the changing.) This apparently is a
minority opinion.
The above was meant to be a workaround: if the title can't be
restored, the second best option seem to be to not have it
changed in the first place.

Another option is, obviously, to have it restored /locally/
after the SSH session is over. And if not by the shell prompt,
then by the code starting the clients itself, like (per xterm(1)):

ssh REMOTE
printf '\033]2;%s\007' DESIRED-TITLE
Post by Eli the Bearded
Post by Ivan Shmakov
Personally, I use Screen under XTerm, configured so that it will use
window's title as its hardstatus,
I use tmux these days, it's roughly the same, but a cleaner codebase
and supposedly better with UTF-8.
AIUI, Tmux has an embedded programming language, which GNU Screen
is currently lacking. (Unless that changed recently, that is.)
Other than that, I don't recall having any issues with the latter,
so there seem to be no incentive for me to switch away from it.

But I guess Tmux is no different to Screen when it comes to
window titles, is it?
Post by Eli the Bearded
I don't use it for every single xterm though.
I rarely have more than a single xterm(1) running at any given
$DISPLAY. One use case is to run an additional instance with a
-misc-fixed- font, which tend to have better Unicode (BMP)
coverage than Terminus (which I use most of the time.)

I typically have a handful of SSH sessions under my one Screen
instance. I suppose were there more of those, I'd be running
additional Screen sessions, and hence XTerms.
Post by Eli the Bearded
Post by Ivan Shmakov
For non-interactive use, I've found dsh(1) quite useful. E. g.: $
Since I don't have passwordless logins configured,
And now I'm curious as to why?

(To think of it, some of my systems don't have /password-based/
logins configured; while others use Kerberos authentication,
which allows for the password to be given once to kinit(1) and
used to run an arbitrary number of SSH sessions from then on.)
Post by Eli the Bearded
I use sshpass in a loop with ssh for that sort of thing.
Can't you do something like $ dsh -rsshpass -ossh?

[...]
Post by Eli the Bearded
Post by Ivan Shmakov
FWIW, I use Rsync to distribute my dotfiles and other useful bits
across my multiple $HOME directories.
See above issue with passwords.
Similarly, with $ export RSYNC_RSH="sshpass ssh"?

[...]
--
FSF associate member #7257 http://am-1.org/~ivan/
Eli the Bearded
2018-08-10 19:12:48 UTC
Reply
Permalink
Raw Message
Post by Ivan Shmakov
I rarely have more than a single xterm(1) running at any given
$DISPLAY. One use case is to run an additional instance with a
-misc-fixed- font, which tend to have better Unicode (BMP)
coverage than Terminus (which I use most of the time.)
It's common now for me to use three or four at once. One with vi open to
take notes about what's going on, one or two with active things (eg
ansible log "tail -f") scrolling by, and one with vi editing code. It is
theoretically possible to do this with a big xterm and tmux window
splitting, but I find focus-follows-mouse to be more convient. I'm often
using the mouse for cut-n-paste anyway.
Post by Ivan Shmakov
Post by Eli the Bearded
Since I don't have passwordless logins configured,
And now I'm curious as to why?
No shared home directory, no existing infrastructure to distribute
passwords, the hassle of the bootstrapping, and an uncertainty of how
that would break / confuse the existing Ansible scripts that expect
a password prompt.
Post by Ivan Shmakov
(To think of it, some of my systems don't have /password-based/
Yes, I have used such systems.

My preferred set-up would be role based accounts on all of these remote
systems and users' ssh keys distributed via Ansible (or the like) to
their allowed role accounts on their allowed hosts.

I'm not here to rebuild that aspect of their infrastructure however, and
I pick my battles accordingly. (Using OS releases new enough to still
getting security updates, for example, is a higher priority push.)
Post by Ivan Shmakov
Post by Eli the Bearded
I use sshpass in a loop with ssh for that sort of thing.
Can't you do something like $ dsh -rsshpass -ossh?
sshpass came installed, dsh didn't.

Elijah
------
also uses their preferred distro rather than his preferred distro
Rich
2018-08-08 01:10:45 UTC
Reply
Permalink
Raw Message
Post by Eli the Bearded
Post by Ivan Shmakov
Post by King Beowulf
If want a sorted list of directories whose *files* where modified,
And it should be used before all the other criteria so to avoid
* a call to dirname(1) can easily be avoided, as find(1) has
-printf "%h" directive;
Good call.
Post by Ivan Shmakov
* there's no need to do a sort(1), as the output is ought to
already be suitable for uniq(1).
Are you sure?
The 'find' command normally outputs the directory listing in the order
it is handed the entries by the kernel/filesystem.

Whether the entries are handed out in already sorted order, or some
arbitrary ordering based on how the filesystem stores them, is
filesystem dependent.

So it is not safe to assume that find's output is always sorted in any
particular desired sort order that a user may wish to receive.
Eli the Bearded
2018-08-08 22:39:11 UTC
Reply
Permalink
Raw Message
Post by Rich
So it is not safe to assume that find's output is always sorted in any
particular desired sort order that a user may wish to receive.
In particular, in this case it was not safe to assume that a directory
might be mentioned more than once with intervening other directories,
which is a bit of a edge case. Because sorting isn't really an
important thing for that code except that the 'uniq' only by checking
consecutive lines, not the whole history.

A point I think you have somewhat glossed over.

Elijah
------
unsorted output is much faster for huge output
Loading...