This isn't built into OSX, but a guy wrote a cli tool called trash that is cross platform and is intended as a safe alternative to rm. As it seems it should, it moves the target to the trash rather than deleting it immediately.
There is more information and instructions on how to install at the trash github page
Answer from dwightk on Stack ExchangeHey guys, I was wondering if there was a way to remove an app fully with Terminal? Whenever I try to remove app and reinstall it with a new version with terminal it's the same old version but a higher size. Can anyone tell me what I am possibly doing wrong?
This isn't built into OSX, but a guy wrote a cli tool called trash that is cross platform and is intended as a safe alternative to rm. As it seems it should, it moves the target to the trash rather than deleting it immediately.
There is more information and instructions on how to install at the trash github page
It is not recommended to use the rm method since you can mistakenly remove wrong file and it is no longer in trash.
But if you must:
Instructions
Type
sudo rm –f(with a space after the f and not including the quotes) to delete a file.Type
sudo rm –rfto delete a folder.Drag and drop the files you wish to delete onto the open Terminal window. The files you drop on the Terminal window will be deleted. You can drag and drop multiple files and folders onto the Terminal window.
Read more: http://www.ehow.com/how_4530950_delete-terminal-mac-os-x.html#ixzz324fT3H5z
YOU HAVE BEEN WARNED !
Videos
I tried to install the new Catalina update, and I guess it didn't have enough space (it didn't say, it started the update process). I don't think it finished, and now I can't get past my login screen without my Macbook (Pro, 2015) shutting down. I've tried everything, and all I can think to do is free up space and re-install Catalina through recovery mode.
I need to free up 4 more gbs of space. I can't get to my applications folder, since I can't log in, so I was wondering how can I use the terminal to do it? I was going to delete my Adobe applications, but when I've followed instructions to get into my Applications folder path, I don't see any of the apps.
Any help/advice would be very appreciated. I really don't wanna have to wipe my drive.
If the application has been installed via the package manager, all you have to do is run
sudo apt-get remove <application_name>
That should always work. If the terminal isn't what stirs your tea, you could open System → Administration → Synaptic Package Manager, search for the package you want to remove, click on the checkbox next to it and select "mark for removal". Once you click "Apply", the package should be removed. There's of course also the Ubuntu Software Center. It's pretty much the same thing as Synaptic. Just search for the application name and click the "Remove" button.
Sometimes applications can be split up into multiple packages (for example, many games have a separate package for their music). To make sure that you uninstall all related packages AND configuration files, you can type
sudo apt-get purge <package-name>
or -in Synaptic- "mark for complete removal" instead of just "mark for removal".
As for applications that have been manually compiled and installed, there's not always a single way to remove them. The best thing to do is consult the README/INSTALL file that accompanied the source package - if one exists.
- The software centre: find the package, click remove

- Synaptic
: the same

apt-get:
sudo apt-get remove <package> && sudo apt-get autoremoveaptitude:
sudo aptitude remove <package>
It's important to note that when you install things, they often depend on other packages. When you fire off apt-get remove <package> it doesn't remove the automatically-installed applications by default. This is often safer (if you're temporarily removing something like ubuntu-desktop) but this can mean you end up with a load of cruft.
aptitude will automatically remove things (as well as having a nice interactive command line interface)
You can also search for cruft in synaptic using the "local or obsolete" filter under the status section.
Trying using the pm command:
pm uninstall <package_name>
or
pm uninstall -k <package_name>
The -k flag keeps the data and cache directories after the package is removed.
I haven't tested this myself, but I don't think this should show a warning message.
To forcefully uninstall the system user apps:
Use:
adb shell pm uninstall --user 0 <package_name>
I'm trying to delete an application on the terminal, as it won't go into my trash. And everytime I use the rm or the unlink commands it said that I didn't have permission. Then I tried Sudo rm and it asked for my password and nothing happened. After that command it disapered from my Files app, but was still openable on the "Show Applications" Menu, and was still showing on my Terminal when I use the command "sudo apt list --installed". (Note I can't delete it from this screen as no matter what I copy and paste it says that no such file or directory exists)