Score:2

What does leading tilde mean in this argument to apt?

er flag

I found this snippet from the ROS installation tutorial.

https://docs.ros.org/en/iron/Installation/Ubuntu-Install-Debians.html

At the bottom, it says to remove all packages, executing the following code snippet:

sudo apt remove ~nros-iron-* && sudo apt autoremove

I want to know what the leading tilde and n signify. I ran apt search ~nros expecting ~n to function as an escape character equivalent to newline, but this did not happen (it also listed packages where ros was in the middle of the package name). Maybe apt search and apt remove parse text differently; I am unsure.

Raffa avatar
jp flag
You can run a simulation first to see what it matches on your system ... APT has an option for that `-s` ... So, `apt -s remove ~nros-iron-*` without `sudo` will tell you what it will match.
Score:5
hr flag

Since version 2.0, apt has supported a search syntax inspired by that of the Debian aptitude tool, and described in the apt-patterns manual page. Specifically ~nname is the short-form of ?name(name)

   ?name(REGEX), ~nREGEX
       Selects packages where the name matches the given regular expression.
Raffa avatar
jp flag
I might not be recalling correctly, but I think it probably makes the match case insensitive as well ... Might be irrelevant to APT though.
hr flag
@Raffa yes that does appear to be the case... do you know anywhere that documents that?
Raffa avatar
jp flag
It's from memory, but I might be not recalling correctly honestly ... APT also has a strange behavior too as it will switch to case insensitive matching as soon as it switches to gobbing or regex mode ... For example adding `*` to either end of the pattern will cause it do so as well ... So it might be hard in case of APT to isolate that to `~`.
hr flag
@Raffa yeah I think you're right - in fact, the changelog has *make apt search case-insensitive by default* as far back as version 1.0.1 so apparently the behavior predates the aptitude-inspired patterns (though I can't say I ever noticed it in practice)
Score:1
us flag

The leading tilde (~) in the command sudo apt remove ~nros-iron-* && sudo apt autoremove is used as a shorthand for the apt search command. Specifically, ~nname is the short-form of ?name(name) ?name(REGEX), ~nREGEX Selects packages where the name matches the given regular expression.

So, in this case, ~nros-iron-* selects all packages whose name contains "ros-iron".

The apt remove command uninstalls the specified packages, but not their configuration files or data files. If you want to remove everything related to the package, you can use the apt purge command instead.

The apt autoremove command removes orphaned packages, i.e. installed packages that used to be installed as an dependency, but aren't any longer.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.