This is the script which i wrote. The logs.txt consists of : In this the expected output is : But the output i am getting is : Can anyone rectify what is the error ? Answer I thinks this problem should be separated multiple problems. How do you think about below code? You can see what these code actually do
Tag: bash
How to match “whitespace” and “OR” condition with bash script?
I want to match a condition in bash containing “whitespaces” and “OR” condition within strings. I am unable to do as i am new to shell scripting, please help as it going to else loop where it is matching ${myarrlin[1]} . I am getting “Centrify is disabled” but i want the co…
Linux tr command not working as expected
I have this password generator: Which works fine as follows: But fails as follows: The tr command is explicitly saying: remove all characters which do not belong to the given set Thus the characters , and . are unexpected. Where do they come from? Answer There’s also another part of tr’s man page …
Pipes in Bash: One at a Time (Line by Line) or All at Once
First, I create 5 files In the following example, xargs seems to get all the results from find via the pipe all at once: In the following example, xargs seems to get all the results from find via the pipe one at a time (line by line): In the following example, xargs seems to get all the results from ‘fi…
How to make the bash script work with one command after another?
I have a bash script like below. First it will take sorted.bam files as input and use “stringtie” tool give each sample gtf as output. Then path for each sample gtf will be given into mergelist.txt. and then use “stringtie merge” on them to get “stringtie_merged.gtf”. I tot…
How to get the process status only with “R” in linux?
–Need to get the status of the background running script. Initially, I ran the script and terminated it turned to stat “T” further, running the same script but while grep getting the script with stat “T”and “R” Here, how to get the process with only “R”. h…
Echo only valid user
Bash newbie question: I’d like to have this script echo out only users from a given list that are valid user IDs, and not echo the invalid ones. Here’s what I have so far: Instead, it is echoing out the results of ‘id’ as well as the text “is not valid user ID” Ideally, it&…
bash: string value based entries filtering
I have this check in my script: It is writing lines that contain contact* from one file to an array. How can I add another check that will skip the xi* values in that line and write it in the array? I tried something like: But it is not working for me. :/ Answer The first file looks like this:
How to capture the output of a top command (for a specific process that will die) in a file
I have a process MYPID=18686 that I am monitoring with top. When the process dies, the output file is empty. My end goal is just to record cpu usage over the lifetime of that process. Specifying -n 1000 -d 5 is a cheap workaround that runs top for the expected lifetime of the process. The tail -1 was to elimi…
Does all linux users are present on /etc/passwd? [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 …