shell

linux - shellscript - “$#” [duplicate]

百般思念 提交于 2021-02-10 22:31:02
问题 This question already has answers here : What does the $# construct mean in bash? [duplicate] (3 answers) Closed 5 years ago . I have a shellscript with the following lines: set -o nounset set -o errexit set -o xtrace if [ "$#" -ne 0 ] then echo 'A message' exit 1 fi Can somebody explain the commands, in particular the setter and the "$#" portion? 回答1: $# is the number of arguments passed to the script. So this if [ "$#" -ne 0 ] check ensures that if no arguments are passed then the script

linux - shellscript - “$#” [duplicate]

眉间皱痕 提交于 2021-02-10 22:27:37
问题 This question already has answers here : What does the $# construct mean in bash? [duplicate] (3 answers) Closed 5 years ago . I have a shellscript with the following lines: set -o nounset set -o errexit set -o xtrace if [ "$#" -ne 0 ] then echo 'A message' exit 1 fi Can somebody explain the commands, in particular the setter and the "$#" portion? 回答1: $# is the number of arguments passed to the script. So this if [ "$#" -ne 0 ] check ensures that if no arguments are passed then the script

linux - shellscript - “$#” [duplicate]

送分小仙女□ 提交于 2021-02-10 22:26:30
问题 This question already has answers here : What does the $# construct mean in bash? [duplicate] (3 answers) Closed 5 years ago . I have a shellscript with the following lines: set -o nounset set -o errexit set -o xtrace if [ "$#" -ne 0 ] then echo 'A message' exit 1 fi Can somebody explain the commands, in particular the setter and the "$#" portion? 回答1: $# is the number of arguments passed to the script. So this if [ "$#" -ne 0 ] check ensures that if no arguments are passed then the script

Merging word counts with Bash and Unix

本秂侑毒 提交于 2021-02-10 19:52:28
问题 I made a Bash script that extracts words from a text file with grep and sed and then sorts them with sort and counts the repetitions with wc , then sort again by frequency. The example output looks like this: 12 the 7 code 7 with 7 add 5 quite 3 do 3 well 1 quick 1 can 1 pick 1 easy Now I'd like to merge all words with the same frequency into one line, like this: 12 the 7 code with add 5 quite 3 do well 1 quick can pick easy Is there any way to do that with Bash and standard Unix toolset? Or

Merging word counts with Bash and Unix

旧巷老猫 提交于 2021-02-10 19:51:53
问题 I made a Bash script that extracts words from a text file with grep and sed and then sorts them with sort and counts the repetitions with wc , then sort again by frequency. The example output looks like this: 12 the 7 code 7 with 7 add 5 quite 3 do 3 well 1 quick 1 can 1 pick 1 easy Now I'd like to merge all words with the same frequency into one line, like this: 12 the 7 code with add 5 quite 3 do well 1 quick can pick easy Is there any way to do that with Bash and standard Unix toolset? Or

ng build command is not working via jenkins build execute shell

大城市里の小女人 提交于 2021-02-10 18:38:18
问题 In jenkins build execute area I put these command: cd /var/lib/jenkins/workspace/test/ ng serve Here is the screenshot: I am getting an error like this: cd /var/lib/jenkins/workspace/test/ ng serve Environment variable TERM not defined! Build step 'Execute shell' marked build as failure Finished: FAILURE node v6.10.0 @angular/cli: 1.0.6 Please help me to resolve this issue. 回答1: Try this I did jenkins integration today. npm run ng build This is working fine. 回答2: In my case my slave Jenkins

how to transpose values two by two using shell?

て烟熏妆下的殇ゞ 提交于 2021-02-10 18:22:57
问题 I have my data in a file store by lines like this : 3.172704445659,50.011996744997,3.1821975358417,50.012335988197,3.2174797791605,50.023182479597 And I would like 2 columns : 3.172704445659 50.011996744997 3.1821975358417 50.012335988197 3.2174797791605 50.023182479597 I know sed command for delete ','(sed "s/,/ /") but I don't know how to "back to line" every two digits ? Do you have any ideas ? 回答1: One in awk: $ awk -F, '{for(i=1;i<=NF;i++)printf "%s%s",$i,(i%2&&i!=NF?OFS:ORS)}' file

PowerShell SendKeys to InternetExplorer ComObject

纵然是瞬间 提交于 2021-02-10 15:56:47
问题 Here's one method I found which brings the IE ComObject window to the foreground and uses SendKeys. How would I send a sequence of key presses using this method? $ie = New-Object -ComObject InternetExplorer.Application $ie.navigate("www.google.com") do {sleep 1} until (-not ($ie.Busy)) Add-Type -AssemblyName System.Windows.Forms Add-Type @" using System; using System.Runtime.InteropServices; public class StartActivateProgramClass { [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType

Set expand_alias when shopt not available?

混江龙づ霸主 提交于 2021-02-10 15:28:13
问题 I'm trying to use an alias in a shell script I'm writing, but it is not working. The alias: alias ts="awk '{ print strftime(\"[%Y-%m-%d %H:%M:%S]\"), \$0 }'" When I run the script, I get the following error: ./copyTask.sh: ts: not found Sooping around on the internet, it seems that I need to enable the expand_aliases shell option, but I don't have shopt installed... Is there any way I can enable alias expansion without using shopt or creating another rootfs image? I'm using the ash shell. And

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