Skip to content
Advertisement

How to get current foldername and remove characters from the name in bash

I’m trying to write a single command in my makefile to get the current folder and remove all “.” from the name. I can get the current folder with $${PWD##*/} and I can remove the “.”s with $${PWD//.} but I can’t figure out how to combine these two into one.

The reason I need this is to kill my docker containers based on name of project. This is my command:

JavaScript

and i was hoping I could inject the project name before my container name like this:

JavaScript

Advertisement

Answer

You can try:

JavaScript

or:

JavaScript

In your use case will be something like:

JavaScript

Note that there are more ways to do that (even more efficient).

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement