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
Tag: for-loop
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
Looping over the last subdirectory to zip in linux terminal
given the following structure: How do I find & zip the last subdirectory in specific directories? The directory starts with ‘b’ (ex) ‘b1’, ‘b2’ Find the last subdirectory and zip it (ex) ‘b14’, ‘b22’ I want something like: The output has to be: Answer Pipe to tail -1 to get the last line.
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
Deleting the first row and replacing the first column data with the given data
I have the directories name like folder1,folder2,folder3….folder10. Inside each directory there are many text files with different names.And each text files contain a text row on the top and two columns of data that looks like as below Then what i want to do is== at first i want to remove completely the first row of all text files present
shell script that runs program that takes two input files
I want to develop a shell script that calls a program that requires two input files. The question is that, it is not only one pair that has to process it, but x number of pairs that are in the same directory. In the directory I have for example: The command line of the program is as follows: And what
Bash: syntax error operand expected “=”, in assignment statement in a for loop
EDIT: I think that it’s not picking up the $1 as the operand. I tried storing it in a variable, then trying the assignment but it seems that has no effect. EDIT 2: provided a minimal reproducible script as requested. The error generating part of the code is the following: the rest of the function’s code will be attached below.