bash

awk sort multidimensional array [duplicate]

痴心易碎 提交于 2021-02-07 08:54:15
问题 This question already has an answer here : Appending an element to associative array awk (1 answer) Closed 4 years ago . GNU awk supports multidimensional arrays: q[1][1] = "dog" q[1][2] = 999 q[2][1] = "mouse" q[2][2] = 777 q[3][1] = "bird" q[3][2] = 888 I would like to sort the "second column" of q such that I am left with: q[1][1] = "mouse" q[1][2] = 777 q[2][1] = "bird" q[2][2] = 888 q[3][1] = "dog" q[3][2] = 999 as you can see the "first column" values moved to keep with the second. I

awk command fails in snakemake --use-singularity

萝らか妹 提交于 2021-02-07 08:45:28
问题 I am trying to combine Snakemake with Singularity, and I noticed that a simple awk command no longer works when using singularity. The $1 in the last line gets replaced by bash instead of being used as the first field by awk . Here is a minimal working example ( Snakefile ): singularity: "docker://debian:stretch" rule all: input: "test.txt" rule test: output: "test.txt" shell: "cat /etc/passwd | awk -F':' '{{print $1}}' > {output}" When I run snakemake without singularity, the output test.txt

awk command fails in snakemake --use-singularity

若如初见. 提交于 2021-02-07 08:44:33
问题 I am trying to combine Snakemake with Singularity, and I noticed that a simple awk command no longer works when using singularity. The $1 in the last line gets replaced by bash instead of being used as the first field by awk . Here is a minimal working example ( Snakefile ): singularity: "docker://debian:stretch" rule all: input: "test.txt" rule test: output: "test.txt" shell: "cat /etc/passwd | awk -F':' '{{print $1}}' > {output}" When I run snakemake without singularity, the output test.txt

How do I get these results in separate automator variables?

孤街醉人 提交于 2021-02-07 08:29:28
问题 I have made a small automator script that runs a bash shell script and gets two outputs... On viewing results it appears like this below... I want them in two automator variables Assume I used a script like echo "200" echo "19 hours, 4 minutes and 42.765 seconds" and on viewing the results it shows this (and I want each of these as automator variables called count and duration ). I want it to be sent to a display notification with subtitle as " count files processed" and message as " duration

How do I get these results in separate automator variables?

柔情痞子 提交于 2021-02-07 08:29:20
问题 I have made a small automator script that runs a bash shell script and gets two outputs... On viewing results it appears like this below... I want them in two automator variables Assume I used a script like echo "200" echo "19 hours, 4 minutes and 42.765 seconds" and on viewing the results it shows this (and I want each of these as automator variables called count and duration ). I want it to be sent to a display notification with subtitle as " count files processed" and message as " duration

Iterate over array of array names expanding each to its members

北城余情 提交于 2021-02-07 08:21:14
问题 I'd like create an array of subarrays made of strings, and get all the subarray values at once for each subarray in the main array. For example, I'm hoping to get "str1" "str2" to print out the first time, but instead it actually prints out "sub1" #!/bin/bash declare -a arr=(sub1 sub2) declare -a sub1=("str1" "str2") declare -a sub2=("str3" "str4") for item in "${arr[@]}"; do echo $item done I want this behavior so I can later call a script and pass "str1" "str2" to an argument that takes two

Iterate over array of array names expanding each to its members

微笑、不失礼 提交于 2021-02-07 08:16:45
问题 I'd like create an array of subarrays made of strings, and get all the subarray values at once for each subarray in the main array. For example, I'm hoping to get "str1" "str2" to print out the first time, but instead it actually prints out "sub1" #!/bin/bash declare -a arr=(sub1 sub2) declare -a sub1=("str1" "str2") declare -a sub2=("str3" "str4") for item in "${arr[@]}"; do echo $item done I want this behavior so I can later call a script and pass "str1" "str2" to an argument that takes two

How can I run docker container without entering into container

[亡魂溺海] 提交于 2021-02-07 08:15:33
问题 I have Dockefile FROM centos:7 So I have no entrypoint in dockerfile. Then I build it to image sudo docker build -t my_container . Then I start it. sudo docker run -t my_container And I get open tty to container root@my_container_id/ If I start it without -t it stopped immidiately after start. How can I run docker container without start tty and without entrypoint? 回答1: You can start your container in a detached mode: docker run -it -d my_container The -d option here means your container will

How can I run docker container without entering into container

会有一股神秘感。 提交于 2021-02-07 08:12:33
问题 I have Dockefile FROM centos:7 So I have no entrypoint in dockerfile. Then I build it to image sudo docker build -t my_container . Then I start it. sudo docker run -t my_container And I get open tty to container root@my_container_id/ If I start it without -t it stopped immidiately after start. How can I run docker container without start tty and without entrypoint? 回答1: You can start your container in a detached mode: docker run -it -d my_container The -d option here means your container will

Why must I source .bashrc every time I open terminal for aliases to work?

心已入冬 提交于 2021-02-07 08:07:51
问题 Git was working fine. I have created an alias in Git but the issue is when I tried to reopen the terminal, then I need to run . ~/.bashrc every time in the terminal. What is the best way I don't need to provide source every time when I reopen the terminal? What I did? I am trying to add source of the .bashrc file in this file but it is a read-only file. I am not able to add the source of the .bashrc file in this profile. open /etc/profile Added the permission to write in the profile as well,