I have two arrays that I need to iterate over but I can’t figure out how to get the combination of both arrays… Answer
Tag: bash
Using sed – how to replace two HTML tags or patterns with unknown content in-between?
I want to leave the unknown content between tags intact, but want to match all tags that use: and replace the surrounding tags with: I’ve come up with the following, but obviously it’s not working as in the second part it’s literally substituting “].*[<]/h2[>]” for each mat…
How to find sequence of characters matching an identifier in Linux/Unix?
I have a fasta file called mytext.fasta. mytext.fasta When I do grep -A1 ‘SS1G_01082’ mytext.fasta, I get: Instead I want to get: If you notice, every sequence starts with > in this file, so I want to get the full length of sequence when I do grep. How can I get this done? Answer It is easier w…
How to open files sequentially on a terminal?
I want to iterate through all files in a directory and open them with an editor, but I don’t want to open the next one until the previous has closed. something like: Answer You don’t have to do anything; the shell blocks until vim exits each time through.
How to ping in linux until host is known with X seconds timeout?
Im trying to wait for a device to boot up in my code and i dont want to use sleep to wait for him. my problem is that sometimes the device fail to boot and im stuck in a loop when using: How can i try to ping to the device for X seconds and print “DEAD” or “ALIVE” using
Stop bash script from dying when exiting Java / Kotlin application
I’m starting a bash script from Kotlin, but the bash script stops running as soon as the Kotlin application exits. Where script is a liquidsoap script and input is a parameter that’s being passed into the script Typically, it’ll run something like the following: liq then executes a liquidsoa…
How can I insert spaces or characters every “n” spaces while tailing a file?
I am tailing a log file and want to make it more readable. The current output is something like this: I want the output to be more like this: It would be great if sed could be used to insert the spaces. The spaces need to be every 8 characters — it will always be in binary data after the
Restart the computer when the power on time exceeds 30 minutes [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack …
Unable to get the output using regex
This might be a silly one, but I’m unable to get the required output. I’ve a file named Abc_sfgf_kjwefgk.txt20180929_040845 in a directory. I’m trying to list the file using the command: ls -l Abc_sfgf_kjwefgk.txt[0-9]{8}_[0-9]{4} But it’s giving me error: ls: cannot access ‘Abc_…
Using bash, I want to print a number followed by sizes of 2 paths on one line. i.e. output of 3 commands on one line
Using bash, I want to print a number followed by sizes of 2 paths on one line. i.e. output of 3 commands on one line. All the 3 items should be separated by “:” I am getting the output as – But I want the output as – Answer This should work for you. The two key elements added being