bash

Wildcard in bash script

。_饼干妹妹 提交于 2021-02-05 09:28:06
问题 I have a bash script to retrieve files from ftp. Now the files have one part a date string in the filename, but also undefined numbers that changes on every file. I want to download the files based on the date. This is my code. I only need to do the wildcard trick, the ftp script is allready work. filename=$(echo $TIMESTAMP'0***vel.radar.h5') The stars are 3 digits with different numbers that i can't estimate, so i would use the wildcard for them. Thank you 回答1: It sounds like you want to

How to pass arguments to bash command [duplicate]

谁说胖子不能爱 提交于 2021-02-05 09:28:05
问题 This question already has answers here : How to pass command output as multiple arguments to another command (5 answers) Closed 14 days ago . I try to pass this result in the third command -d argument, But i failed. $ cat asnlookups_domains_ip.txt | awk '{print $1}' | amass intel -whois -d flag needs an argument: -d 回答1: You could try xargs : cat asnlookups_domains_ip.txt | awk '{print $1}' | xargs -n1 amass intel -whois -d It passes the standard input as arguments after your command. 来源:

What does this shell test achieve

独自空忆成欢 提交于 2021-02-05 09:25:32
问题 I have a very simple question that I can't answer. In shell, what would this command do: test -d $VIRTUAL_ENV || virtualenv $VIRTUAL_ENV It seems like it tests if the virtualenv directory exists, but I dont understand what if does with that information. Will it always create the virtualenv afterwards, or would it only do it if it doesn't already exist? 回答1: The || is the OR condition. Hence, this will test if $VIRTUAL_ENV directory exists. If not, it will run virtualenv $VIRTUAL_ENV . Other

Unable to read from user in rpm install script

£可爱£侵袭症+ 提交于 2021-02-05 09:24:08
问题 I've Created RPM Package which contains shell script code which shown below. When I'm installing it in RedHat OS, It is not taking user input and continuously looping. If I run the same file manually it's working fine. If Anybody Knows Please let me know. set +e IpAddress='0' condition=1 while [[ $condition -ne 0 ]] do echo ' ' echo "PLEASE PROVIDE APPLIANCE IP" read IpAddress if valid_ip $IpAddress; then condition=0 else echo $IpAddress " IS INVALID IP PLEASE PROVIDE A VALID IP: " echo ' '

adding && \ to each line on a text file except last line

点点圈 提交于 2021-02-05 09:11:46
问题 I'm trying to add && \ on end of each line on a text file except the last line. Sample input: ps mkdir repo cd repo/ touch file1.txt Expected output: ps && \ mkdir repo && \ cd repo/ && \ touch file1.txt First attempt I tried this, but it outputs && \ on each line including the final line : awk '{print $0"&& \\"}' RS="\r*\n\r*" Second attempt I tried using sed: sed '1s/^//;$!s/$/"&&" \\/;$s/$//' This seems to add extra newlines: ps && \ mkdir repo && \ cd repo/ && \ touch file1.txt 回答1: You

create unix alias using a python3 script

爷,独闯天下 提交于 2021-02-05 09:11:45
问题 Well, as we all known, creating an alias in a terminal shell is quite easy: ZZ:~ zhangzhao$ alias c='uname' ZZ:~ zhangzhao$ c Darwin ZZ:~ zhangzhao$ But now I want to do the same thing through a Python3 script. I've checked the ref manual and found these sort of command work can be solved using subprocess module. Then I write the script below: import subprocess subprocess.call(["alias", "c=\'uname\'"]) But note that this operation will not take effect to the shell you are currently using,

adding && \ to each line on a text file except last line

北城余情 提交于 2021-02-05 09:11:38
问题 I'm trying to add && \ on end of each line on a text file except the last line. Sample input: ps mkdir repo cd repo/ touch file1.txt Expected output: ps && \ mkdir repo && \ cd repo/ && \ touch file1.txt First attempt I tried this, but it outputs && \ on each line including the final line : awk '{print $0"&& \\"}' RS="\r*\n\r*" Second attempt I tried using sed: sed '1s/^//;$!s/$/"&&" \\/;$s/$//' This seems to add extra newlines: ps && \ mkdir repo && \ cd repo/ && \ touch file1.txt 回答1: You

create unix alias using a python3 script

好久不见. 提交于 2021-02-05 09:11:23
问题 Well, as we all known, creating an alias in a terminal shell is quite easy: ZZ:~ zhangzhao$ alias c='uname' ZZ:~ zhangzhao$ c Darwin ZZ:~ zhangzhao$ But now I want to do the same thing through a Python3 script. I've checked the ref manual and found these sort of command work can be solved using subprocess module. Then I write the script below: import subprocess subprocess.call(["alias", "c=\'uname\'"]) But note that this operation will not take effect to the shell you are currently using,

adding && \ to each line on a text file except last line

余生颓废 提交于 2021-02-05 09:11:01
问题 I'm trying to add && \ on end of each line on a text file except the last line. Sample input: ps mkdir repo cd repo/ touch file1.txt Expected output: ps && \ mkdir repo && \ cd repo/ && \ touch file1.txt First attempt I tried this, but it outputs && \ on each line including the final line : awk '{print $0"&& \\"}' RS="\r*\n\r*" Second attempt I tried using sed: sed '1s/^//;$!s/$/"&&" \\/;$s/$//' This seems to add extra newlines: ps && \ mkdir repo && \ cd repo/ && \ touch file1.txt 回答1: You

adding && \ to each line on a text file except last line

倖福魔咒の 提交于 2021-02-05 09:07:52
问题 I'm trying to add && \ on end of each line on a text file except the last line. Sample input: ps mkdir repo cd repo/ touch file1.txt Expected output: ps && \ mkdir repo && \ cd repo/ && \ touch file1.txt First attempt I tried this, but it outputs && \ on each line including the final line : awk '{print $0"&& \\"}' RS="\r*\n\r*" Second attempt I tried using sed: sed '1s/^//;$!s/$/"&&" \\/;$s/$//' This seems to add extra newlines: ps && \ mkdir repo && \ cd repo/ && \ touch file1.txt 回答1: You