Skip to content

Tag: bash

preserve inline variable with sudo

Hi i’m trying to make something like this to work in bash but i keep getting an empty line, the only thing that works so far is: what i would like to achieve is the ability to inline a variable for the sudo command i also tried this as suggested here but with no luck, am i missing something? Answer

How to insert variable containing a path into sed

I’m writing a linux script, which is to replace a string for a file. Here is my script: In the file named test, there is a line like this: What I need is to replace this line with the line below: It means that things between double quotes should be replaced by the $var. However when I execute my script,

Bash passing arguments to a command

I need to execute in Bash the following command: The thing is that in Linux the ‘;’ character is indicator of end of the command and I also need to use environment variables. How can I do this? How can I achieve this? Answer The answer from @ilkkachu is on the money, as is chepner’s comment …

Bash text multi line into one line with spec. data

I got something like this And I need this I am new with the bash and I dont know how can I get this Thanks for you help! EDIT Answer Use sed and paste, as in Of course, if you have multiple records/albums/tracks, or if the field names may change, there are better solutions.

Email based on value of report

I’m looking to grep a numeric value from a tripwire report, and if the value is greater than 0, send an email. The script so far looks like this: Not sure how to grab the value and set it as a variable or if there’s a way to include it in the if statement itself. Answer First count the entries: