Skip to content

Tag: bash

Increment variable when matched awk from tail

I’m monitoring from an actively written to file: My current solution is: However when attempting to do this with AWK I don’t get the output – the $ws_trans and $sc_trans remains 0 Attempting to do this to reduce load. I understand that AWK doesn’t deal with bash variables, and it can g…

reading file line by line in an infinite loop until break

I’m trying to implement an infinite loop bash script for reading in a file, doing something and check counter condition, when counter condition reaches 0 it breaks out of the infinite loop. I’ve tried several iteration and none has worked for me. Pseudo-code would be something line this.. Can anyo…

using for in loop with sql output

I have a roles.txt file that contains SELECT ROLE_NAME FROM SENTRY_ROLE WHERE ROLE_NAME produces: Im trying to echo all the roles from roles.txt that are not in the sql_output (user in this example). This is what i have so far: Answer That’s not how you iterate over the lines of a file. See http://mywik…

Converting from batch to shell

I have a set of batch commands that I’m trying to convert to shell so I can use them on my linux environment. The command should read In windows (using batch), running this command should produce a set of files that are numbered like this: 0001_inside.hdr 0002_inside.hdr etc. However, when I ran this co…

echo does not print a variable in bash

I’m facing a very strange issue. I have 2 files ber_log_before.txt and ber_log_after.txt. Their contents are ber_log_before.txt ber_log_after.txt There are $ it’s normal. Then I wrote a basic bash command to parse them Why 1st val 14 2em val 24 is not echoed??? If I replace by Then at least I have…

Bash Create Directories/Subdirectories Using Two Lists

I would like to create a number of directories, each with a number of subdirectories based on two lists using Bash. Currently, the below code achieves this result: Yields Question: Is there a cleaner (non-single-line) way to achieve the same result, perhaps storing the two lists as arrays or variables and usi…

Return the ls -l output in docker container

So I have a docker container running which has a couple of folder/files inside. When I go inside the container I can see that they are: hostmachine$> docker exec -it testContainer bash testContainer@testContainer:~$ ls -l My question is: What script, how can I use it on my hostmachine that will: 1) Echo ba…