Skip to content
Advertisement

Tag: for-loop

How to populate json file with data from bash variable

I am writing a small bash script and I am stuck. I have a text file with some information and I stored the contents of that file in a bash variable. My tools.txt file looks like this: And so on. What I want is to dynamically create a JSON file named tools.json and to populate that file with the content

aws cli describe cluster error using ‘for loop’

I’m having trouble trying to run a for loop with the aws cli command aws eks describe-cluster. I receive the below error on execution. My scripting is not the best. Any help would be greatly appreciated. Thanks. If I simply run aws eks list-clusters | grep dev-shark it outputs the below: It seems to be the comma (,) that is

Looping over pairs of files

Hello I need to iterate over pairs of files and do something with them. For example I have 4 files which are named AA2234_1.fastq.gz AA2234_2.fastq.gz AA3945_1.fastq.gz AA3945_2.fastq.gz As you can propably tell the pairs are AA2234_1.fastq.gz <-> AA2234_2.fastq.gz and AA3945_1.fastq.gz <-> AA3945_2.fastq.gz (they share the name before _ sign) I have a command with syntax looking like this: initialize_of_command file1

run a command with a file pattern

I have this file patterns.txt And I want to run a specific command for every pattern like this: I tried to used for loop like this: but i didn’t work Answer The 2 typical approaches are: and Note that I would expect both of those to fail, since scp expects at least 2 arguments. How you want that 2nd argument

Nested bash loop runs but logic is not correct

I have this nested bash for loop where the first loop represents the range of servers, and the second loop reads each lines of the .txt file. Then will do a zgrep -i and find for a string on the matching line. keys.txt is as follow: Bash Loops: This runs but its logging every instance where ‘InitialRequest’ is defined. What

splitting the file based on repeatation

experts i have a file as below where first column is repeated 0.0,5.0,10.Now i want to split the third column at repeatation of the first column row and want to arrange the data side by side as below: so that my final file will be so that my final file will be Answer Using GNU awk: Process each line and

Advertisement