'Strip text from string in shell script

I have the variables below in a large and important SH file and I need to remove some data from a variable and keep only part of the text.

I get "repoTest" with a link to an internal git repo and I need the variable "nameAppTest" to only receive the constant data after the last "/".

Example:

I get: repoTest="ssh://[email protected]/code/ecsb/name-repo.git"

I try to do a split: nameAppTest=$(echo "$repoTest"|cut -d'/' -f5|sed -e 's/.git//g')

Response I get: echo "$nameAppTest" (ecsb).

What I expect to receive: name-repo

I tried like this and failed: nameAppTest=$(echo "$repoTest"|cut -d'/' -f5|sed -e 's/.git//g')



Solution 1:[1]

Can you just try this.

Try this method to add new User and test it with Postman :

router.post("/addUser", async (req, res) => {
  try {
    var newUser = new User({
      name: "Elliot Alderson",
      age: 23,
      isAdult: true,
    });
    const newUser = await User.save();
    res.send(newUser);
  } catch (err) {
    throw err;
  }
});

Otherwise Log in to your mongo account and add your IP address from the Network Access part. or allow access from anywhere to your database.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hadj Hassine Jawher