Menu

How to move or rename a directory in linux?

If you are moving or renaming a directory within the same directory then use the below command

mv <directory-name> <new-directoy-name>

e.g. mv new-folder new-2016


PS: If you want to move to a different directory then pass the complete path instead of just passing the folder/directory name

Docker vulnerabilities and fixes

 Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

How to get a segment from a URL using JS?

We can find a text or get a segment from a URL or web address using the JS split and slice function. Below is an example of a slice and split function in simple JavaScript code.

Lets assume we have a URL: https://rashidjorvee.blogspot.com/content/2015/javascript:getName_function/12032/live.html

When we run the split based on colon(:) it will return as below.

e.g. window.location.href.split(":").pop()

result ==> getName_function/12032/live.html

Now, from this if you want to read only few characters from any index, then do the slice on the URL.

e.g. window.location.href.split(":").pop().slice(0,7);

result ==> getName