Lurker News
A command line trick, a random factoid, anything that’s interesting to you.

Comments (762) 128 threads

Earlier comments
kretaceous3 replies#
Take a positive integer. If it's odd, multiply it by 3 and add 1. If it's even, divide it by 2.

Example:
7-22-11-34-17-52-26-13-40-20-10-5-16-8-4-2-1-4-2-1-4-2-1...
Any positive integer you take, you end up in a 1-4-2-1 loop.
It's not proved yet but there's no number found yet that satisfies otherwise. That's the Collatz Conjecture or the 3n+1 problem.
Probably the easiest conjecture to explain to someone.
Good day/night!

maddynator3 replies#
Very interesting. whats the use case of this?
kretaceous1 reply#
Well, no particular use case I can think of. The OP asked for anything that you find interesting so here we are. =)
BizarroLand1 reply#
I'm sure there is a use for it, that pattern may be representative of some other phenomenon in the universe that we haven't correlated it to as of yet.

Continue this thread — 1 reply

contingencies#
Impressing ladies at the bar with your 'deep connection'.
mhh__3 replies#
If it's proven then we can add a new pointless compiler optimization (some of them are already allowed to assume some things never terminate, even)
exikyut3 replies#
What's the most pointless compiler optimization you're aware of?

(Obviously a subjective question in practice, so chances are you might need to add a bit of qualification)

Continue this thread — 3 replies

pilaf#
Surely it's true for every unsigned 64-bit integer.
onion2k1 reply#
Presumably there's a reason why it's hard to prove either true or false, right?
remus1 reply#
Depends what you mean by a good reason I guess. A lot of very capable mathematicians have put time in to the problem and it's proven to be pretty resistant to a solution. I think problems like this often feel a little incongruous because they are so simple to state but so hard to solve.
someweirdperson4 replies#
It is easy, we can spit it into two parts: Proving that all even numbers end up in that loop and proving that all odd numbers do.

I'll take the even ones. Who works on the odd ones?

Continue this thread — 4 replies

Aidevah1 reply#
One of Bach's most famous church cantatas, BWV 140[1], was written for the 27th (or no. 3^3, the importance of this will be apparent in a moment) Sunday after Trinity, the last possible Sunday before Advent.

The cantata is a chorale cantata based on the Lutheran Hymn "Wachet auf, ruft uns die Stimme", the opening movement is a chorus that is based on this tune. The tune is in Bar form, the first 3 verses are repeated, followed by 6 verse which is sung once through (3x2 + 3x2), and Bach's chorus mirrors this structure. Bach decided to set the piece in E-flat, which is a key signature with 3 flats. He also decided to make the time signature 3/4, so each bar has 3 beats. There are 3 groups of musicians involved (not counting the obligatory basso continuo): 1) vocal forces, 3 parts (Soprano + Alto + Tenor, the bass mostly doubles the basso continuo and is not independent); 2) strings, 3 parts (violin 1 + violin 2 + viola); 3) winds, 3 parts (oboe 1 + oboe 2 + alto oboe). Also, the opening melody of the chorale outlines the 3 notes of the tonic triad of E-flat (E-flat, G, B-flat), while later on, Bach being Bach, there is a miniature fugato where the three lower voices open with the same 3 pitches in a different order (G, B-flat, E-flat).
I'm usual sceptical of most other numerological readings of Bach's music precisely because when Bach wished to make a point with numbers, he makes it damned obvious, as in this case.
[1] https://www.youtube.com/watch?v=WfNeJ-Cedeo

ZoomZoomZoom#
Obligatory mention of "In The Name Of Ron" by guitarist extraordinaire Ron Jarzombek. For those interested in creative exploration of musical ideas.

https://youtu.be/YYlzPWEQhLg

hiisukun8 replies#
In a lot of terminals, Alt+. (or Option+. on Mac) will paste in the last argument of the previous command.

    $ mkdir hi
    $ cd
You can hit . several times to cycle through earlier final args.
burner556#
or .
schoen2 replies#
Wow, I did not know that!

I would have referred to this using !$, which is one of the Bourne shell history substitutions. Like

  $ mkdir awesome
  $ cd !$
(The "!" has the connotation "history" in the shell, while the "$" has the connotation "last", as in regular expressions.)

An advantage of the way you mentioned is that you could actually see the history item displayed on the command line before running the command!

senjin2 replies#
I use !$ multiple times every day but you just helped me make the connection to try !^ for the first argument and I think I'm going to start using that as well. Thanks!
schoen1 reply#
There is also "!!" for the entire prior command line. Someone elsewhere in this thread mentioned the usefulness of

  sudo !!
for "run the entire previous command under sudo".

Another example could be

  echo "!!" > myscript
for "save the previous command into the file myscript".

Continue this thread — 1 reply

aasasd1 reply#
At least in zsh, there are also !:1 for the first argument, et cetera with the rest of natural numbers, and something like !:* for all the arguments without the command.

The generic form is !n:m for n-th last command line and m-th argument, with an omitted n being a shortcut for the last line.
Not sure if all of this works the same in bash.

Continue this thread — 1 reply

gnubison1 reply#
History expansion originated in csh, and was never in the Bourne shell. Bash, certainly.
schoen#
Thanks for the correction. I often recognize when bashisms are bashisms, but I didn't realize that was.
sph#
Holy shit, I have gone 35 years without ever learning this fact.
I_complete_me#
zsh has "take" to mkdir and cd to it. Something like take() { mkdir -p "$1" && cd "$1" }
sbergjohansen1 reply#
!! substitutes the last command:

  sudo !!
and

  cd -
takes you to the previous directory.
Beldin#
!$ substitutes the last command's arguments, if memory serves.
mikevin#
man 3 readline

to make sure you don't end up with something like urxvt-readline(1)

pards2 replies#
Or ^r to search through the command history (bash only?):

    $ grep blah *
    $ ^r
    (reverse-i-search)`g': grep blah *
This is far and above my most commonly used shell command
onos#
Aweful. The government should be liable for this.
exikyut#
(2001)

I wonder what aspects have gotten worse over the years and how the dynamic has shifted, if at all. Or maybe it doesn't matter this was from 20 years ago? :<

ZeroGravitas1 reply#
Depends on whether you interpret something being on the news as a measure of how common it is.

This is often demonstrated with the two hypothetical headlines "Dog bites Man" vs "Man bites Dog".
One is expected based on its ubiquity, and so a poor headline, where you want some emotional reaction to hook readers.

mellosouls2 replies#
True - and a good point - but also a troubling one as the clear implication is that male suffering is really not considered a concern - at least to the news platforms.

Continue this thread — 2 replies

Continue this thread — 5 more replies

Load more comments