I have two containers running on a host. When I’m in container A I want to run a diff on container B compared to it’s image to see what has changed in the filesystem. I know this can be ran easily from the host itself, but I’m wondering is there any way of doing this from inside container A,…
Tag: bash
Set an external variable in awk
I have written a script in which I want to count the number of columns in data.txt . My problem is I am unable to set the x in awk script. Any help would be highly appreciated. data.txt file: Expected output: My output: Answer You just cannot import variable set in Awk to a shell context. In your example the
Hide information during bash debug run
We do debug run(bash -x ./my_script.sh) in a shell script to understand/show what it is doing. But in doing so it might show some sensitive information that I dont want to be visible, such as passwords. My script extracts the password from a secure vault and passes it as a variable within the script when requ…
grep lines that contain 1 character followed by another character
I’m working on my assignment and I’ve been stuck on this question, and I’ve tried looking for a solution online and my textbook. The question is: List all the lines in the f3.txt file that contain words with a character b not followed by a character e. I’m aware you can do grep -i R…
Send KillAll to multiple node process and wait response
I’m creating a script that makes some pull from a git repository. but first i want to send a SIGUSR1 to multiple nodes that i have running in the machine, and once all the procesess stop i will proceed to git pull so basicly i will run because my node is doing an infinite loop, i want to intercept this
more than one source of data to process with bc
I have this file that contains number in a column: I need to add them together so I do this: But after I add them together I need to divide them by 60,something like this: how can I do that? Answer
having an issue with my bash script
im writing a script that allows the user to create a backup of a file they choose by allowing them to input the file name. the file will then have backup followed by being date stamped at the end of it’s name and saved on the home drive. but whenever i try to run it i get an error: cp:
How can I pass in this echo statement into my function in bash?
So in my while loop I am trying to figure out how to pass in the echo statement into my function bitToSixtyFour as a parameter. It is saying that bitToSixtyFour is not found. Answer As defined the function takes argument $1 from command line : to read from standard input read it would be more efficient to use…
Bash: Cut current path until a certain folder
lets say I have three bash files in different directories: If I call $(pwd) I get the path of the current directory. Is there a way to somehow “crop” this path until a certain folder? In the following an example is shown if the certain folder would be called “c”: In the case of script1…
Compare multiple columns for each row
Using a csv file, i will like to compare multiple columns to check if all values are the same or not. First row are the headers First column is the label The constant values should be from column 2 to the end ( can be 100 columns ) for the example i put only 8 columns. The purpose is to