I’m automating the file creation from a bash script. I generated a file rc_notes.txt which has commit messages from two tags and want to re-write that in a new file as rc_device.txt. I want the user to write the customer release notes and exit from the BASH STDIN that I prompt in the terminal. The probl…
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,
How to remove some string with awk/sed or another command in linux?
I want to ask, how I can remove some string with command in linux? and the output: Answer try: Making field separator as | then substituting the starting zeros with NULL of 111th field as per your requirements, mentioning 1 will print the newly edited line(if any zeros were replaced with NULL), setting Output…
Is there any drawback to using functions instead of aliases?
Bash functions are more versatile than aliases. For example, they accept parameters. Is there any drawback to going full function style and completely drop aliases, even for simple cases? I can imagine that maybe functions are more resource intensive, but have no data to back that up. Any other reason to keep…
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 error “command not found” running a command stored in var
Context: I want to run a command stored in a variable in bash. My bash file: Problem: When I run this bash file, the grunt sass command throws an error: mybash.sh: line 25: $’E[4mRunning’ : command not found Whole return of my bash: Investigation: The commands echo “$(docker exec compose_cus…
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:
Find lines starting with “t”, continue with a vowel and total length 4
I have a file with containing 300+ words. I need to find lines starting with “t”, continue with a vowel and total length of 4. Then i need to convert them in to a format where each line have one word. With this I’m able to format the file but i cant figure out how can i select words with