bash

Evaluate expression inside bash for loop [duplicate]

非 Y 不嫁゛ 提交于 2021-02-10 15:16:19
问题 This question already has answers here : How do I iterate over a range of numbers defined by variables in Bash? (20 answers) Closed 5 years ago . If I do this, I get the result as expected. for i in {125..129}; do echo $i; done 125 126 127 128 129 But when I do this? I get something weired. for i in {$((1+(25-1)*500))..$((25*500))}; do echo $i; done {12001..12500} I wish to pass a variable inside the loop variables like $((1+($j-1)*500)) 回答1: Bash's brace expansion has limitations. What you

Evaluate expression inside bash for loop [duplicate]

别来无恙 提交于 2021-02-10 15:14:16
问题 This question already has answers here : How do I iterate over a range of numbers defined by variables in Bash? (20 answers) Closed 5 years ago . If I do this, I get the result as expected. for i in {125..129}; do echo $i; done 125 126 127 128 129 But when I do this? I get something weired. for i in {$((1+(25-1)*500))..$((25*500))}; do echo $i; done {12001..12500} I wish to pass a variable inside the loop variables like $((1+($j-1)*500)) 回答1: Bash's brace expansion has limitations. What you

jq merge arrays inside object [closed]

假装没事ソ 提交于 2021-02-10 15:11:44
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago . Improve this question I have two objects { "a": [ "1-1", "1-2" ], ... } and { "a": [ "2-1", "2-2", "2-3" ], ... } there are other keys in both objects, but I don't care for them. What I want to get is the object where elements of "a" will be concatenated: { "a": [ "1-1", "1-2", "2-1", "2-2", "2-3"

awk syntax errors with double star **

烂漫一生 提交于 2021-02-10 14:59:45
问题 I'm using Debian 6 and GNU sed, trying to get awk to convert the output of du from a long string of bytes to a more human readable number with suffixes like Mb and Kb. (I know you can use the -h option, but I want to do this manually with awk.) So far, my command looks like this (I put in the newlines to make it more readable): du /test.img | grep [0-9]* | awk "{ sum=$1 ; hum[1024**3]='Gb';hum[1024**2]='Mb'; hum[1024]='Kb'; for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf '%.2f %s\n'

awk syntax errors with double star **

只愿长相守 提交于 2021-02-10 14:57:12
问题 I'm using Debian 6 and GNU sed, trying to get awk to convert the output of du from a long string of bytes to a more human readable number with suffixes like Mb and Kb. (I know you can use the -h option, but I want to do this manually with awk.) So far, my command looks like this (I put in the newlines to make it more readable): du /test.img | grep [0-9]* | awk "{ sum=$1 ; hum[1024**3]='Gb';hum[1024**2]='Mb'; hum[1024]='Kb'; for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf '%.2f %s\n'

configure confixtx.yaml file?

限于喜欢 提交于 2021-02-10 14:47:18
问题 I'm trying to build a Hyperledger Fabric network with the following Smartforce[Orderer Org] Falcon.io [ORG1] Frost.io [ORG2] I have generated all cryptographic materials using cryptogen tool. now looking to build gensis block using configtxgen tool. Here is configtx.yaml : Profiles: TwoOrgOrdererGenesis: Orderer: <<: *OrdererDefaults Organizations: - *Smartforce Consortiums: SampleConsortium: Organizations: - *BusinessPartner1 - *BusinessPartner2 TwoOrgChannel: Consortium: SampleConsortium

configure confixtx.yaml file?

自作多情 提交于 2021-02-10 14:46:03
问题 I'm trying to build a Hyperledger Fabric network with the following Smartforce[Orderer Org] Falcon.io [ORG1] Frost.io [ORG2] I have generated all cryptographic materials using cryptogen tool. now looking to build gensis block using configtxgen tool. Here is configtx.yaml : Profiles: TwoOrgOrdererGenesis: Orderer: <<: *OrdererDefaults Organizations: - *Smartforce Consortiums: SampleConsortium: Organizations: - *BusinessPartner1 - *BusinessPartner2 TwoOrgChannel: Consortium: SampleConsortium

How to create an bash alias for the command “cd ~1”

拈花ヽ惹草 提交于 2021-02-10 14:19:57
问题 In BASH, I use "pushd . " command to save the current directory on the stack. After issuing this command in couple of different directories, I have multiple directories saved on the stack which I am able to see by issuing command "dirs". For example, the output of "dirs" command in my current bash session is given below - 0 ~/eclipse/src 1 ~/eclipse 2 ~/parboil/src Now, to switch to 0th directory, I issue a command "cd ~0". I want to create a bash alias command or a function for this command.

bash script with double for loop over multiple arrays with access to array names

ぃ、小莉子 提交于 2021-02-10 13:49:10
问题 I'm using rsync to copy specific files from a source directory (and subdirectories) to a destination directory (and subdirectories). The mapping of the subdirectories is not identical, so I'm defining arrays of subdirectories of the destination directory that contain the source file paths. I've been unable to successfully loop over the destination arrays with access to the names of the arrays. Here's a MWE (filenames and directories must be edited, obviously). #!/bin/bash sourcedir=~/Dropbox

Add/Replace URL Scheme in Info.plist using bash script

↘锁芯ラ 提交于 2021-02-10 13:48:13
问题 I want to add/replace the URL scheme in Info.plist file using bash script/command. I tried with sed command with various patterns but not succeeded. We want to automate the build generation using Jenkins and our URL Scheme can be changed for various builds, so we want to modify the Info.plist file such that we can either add a new URL Scheme if not there or replace the existing one using script/commands. Please suggest the command to achieve this. 回答1: Task set different url schemes for