Skip to content

Tag: bash

loop to test all NFS mount point

this code work very well If I try to put it into a loop for : Aim is to test all mounts points, this code test and read only the first entries from nfs_array. If I swapped testnfs1 with testnfs2 this code will test testnfs2 mount point and forget testnfs1 🙁 Answer In your loop it should be: Currently it&#8217…

Are there any solutions to this command(shell code) problem

I have some shell codes looks like: but, get an error “-bash: syntax error near unexpected token `(‘” which i can’t fix it. I do know the pipeline command can also do it well. likes but actually I wish to do something in the loops like change the global value and the pipeline didn&#821…

`sudo` with command substitution

I’m working with a remote machine that requires sudo for most docker commands. I often have to perform multiple repetitive commands to stop docker containers, etc: sudo docker stop <container_name>. Normally, I’d use docker stop $(docker ps -q) to stop all the results of docker ps -q, but si…

How do I get just the filename from lsof?

I want to use lsof to create a list of open files in a folder. I’m using macOS, but understand this is common to *nix. In man lsof, it seems the the -Fn option is closest to what I want, but I can’t get further than that. I’m piping to cut to get to just the filename. So this is

Remove part of a string by using bash

I have the path /home/bamboo/bamboo-agent-home/xml-data/build-dir/NG-VOSGQL239-JOB1 and would like to get just /home/bamboo/bamboo-agent-home/xml-data/build-dir/ How can I delete the last part of the path if it can be with different lengths by using Bash? Answer Using bash regex =~: