Skip to content

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…

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

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