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’…
Tag: bash
Is there a way to sort the groups in an ansible host file without sorting the hosts within the groups?
In an ansible host(or inventory) file, you can group host using brackets. I want to sort these groups using sort function in linux but it will sort the individual hosts, and I want the right host to still be under the correct group. For example, I’m looking for a way to sort by group while keeping the h…
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̵…
Reverse sort 3rd numeric column in file
In bash shell scripting, I have users.txt file. sort -t: -k 3n users.txt gives me This is ok. But I need 3rd column which contain only phone number in reverse order i.e. descending order. How to achieve that? I need like Answer You could add an r (short for “reverse”) to the order column specifica…
`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
Gnuplot : 2 questions about my histograms X axis and add percentage
I need to generate a gnuplot histogram in order to see the CPU and RAM evolution of my cluster per month : I want to generate the histogram from this file : To do that, this my code : For the moment, I have this result : But as you can see, I have a problem with my x axies.
Printing current time in milliseconds or nanoseconds with printf builtin
We can print the current time with the builtin printf function, without needing to invoke an external command like date, like this: How can we make printf to print milliseconds or nanoseconds as well? Using %3N or %N in the format string doesn’t work: However, the date command works fine: This is on a R…
How to select a specific range of rows from a text file with bash script [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 3 years ago. Improve this question I wan…
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 =~: