I am trying to capture the total used memory in % on remote machine as the following so we add backslash as before the “$” as but still with the same errors any advice how to fix this syntax? Answer You also have to escape the double quotes “:
Tag: bash
How to send emails via cron job usng Golang MySQL?
Hope you all doing well. how can i using cron job and cron tab(by golang connection my sql) or anothor way using bash script excute (file golang) how can i do that. in crontab -e : set the code 31 17 * * * cd /home/shanaz/Desktop/GO export/home/shanaz/Desktop/GO:bash sql.sh when sql.sh code here go run sqll.go Answer Hope you’re doing well
Sed to replace a speccificc part of line by argument in shell script based in line number
I have a script test.sh He has some arguments like : I made a while read loop to replace each specific part of a line (extractReplaceArgLine) with argument passed in shell script (Forest Cuba World Hello). Consider the file test.txt : So, the output would be : How can I do that ? Thanks ! Answer Use $1 to get
Why does bash go into an infinite loop?
I was trying out different ways of emulating a boolean variable in bash. One method is: which prints true and false respectively. Then I had a brain cramp and typed: expecting to see yes in the terminal. However, without the echo command, it went into an infinite loop printing y. Can someone explain what bash is doing here? Answer bash
Extracting group from regex
I am new to using regex and having some issues understanding how to extract a group from a regular expression. I have a text file (example.txt): I am trying to extract the “5.2.1” only from the libpackage line and put it into a variable for a bash script. I have tried doing But it gives me the entire line instead
How to find all the files created today and modified anytime before 5 minutes?
Let’s say it is 10:00 am when the command is run, I need to list the files modified between midnight and 9:55 am. I have tried the following command which looks logical as per the documentation but it is pulling all the files since yesterday. Answer Since -daystart isn’t that portible, consider a solution like so; Use $(date +”%H”) to
How to install new relic on amazon linux
I have have unzipped newrelic files onto amazon linux and have both the installer.sh and config_defaults.sh I have the license key in the parameter store which I am able to call I install newrelic with the following command Where APPIKEY comes from the parameter store. However when I do sudo systemctl start newrelic-infra I get error message How can I
unzip a list of archives
I need to Unzipped a list of zip archives. These archives are not empty, in each one there are a lot of file. In my directory I have a lot of file zip archive and all have the the name in the same format: batch-download-ccd-1610959358275.zip but change only the numeric part. I can extract each archive with unzip command but
How to search /var/log/dpkg.log for monthly install/upgrade logs and output to text file
I would like to output a file with install/upgrade logs limited to the past month by looking in /var/log/dpkg.log. I do not know bash, I know that the grep command could make it, but I still need some help. Answer Sample output:
Bash script : problem with my substraction
I would like to make a script that will calculate the difference of download time between two curl. For example with this command : My curl command will be run each day and I would like to make a substraction between the value of the day and the value of the previous day. For that, I will save the time_total