shell

mv a file that contains spaces from a shell script

╄→尐↘猪︶ㄣ 提交于 2021-02-07 14:48:40
问题 I am trying to mv a file (rename it to replace spaces with dashes). If I pass the source and dest arguments without quotes, the source is broken up because mv thinks it is the end of the argument. If I surround source and dest with arguments, mv reports that the source can't be found. Currently, $1 and $2 have hardcoded quotes at the beginning and end. $onam and $dnam are the equivalents without the hardcoded quotes. This command from a prompt works perfectly because source and dest are

What is the difference between . and ./ in bash? [closed]

余生颓废 提交于 2021-02-07 12:48:27
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question Running this command (where a.out is a valid C executable): . a.out ...results in this error: bash: .: a.out: cannot execute binary file However, running the following command: ./a.out ...successfully executes the C binary executable. Clearly, there are 2 types of

What is the difference between . and ./ in bash? [closed]

一个人想着一个人 提交于 2021-02-07 12:47:21
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question Running this command (where a.out is a valid C executable): . a.out ...results in this error: bash: .: a.out: cannot execute binary file However, running the following command: ./a.out ...successfully executes the C binary executable. Clearly, there are 2 types of

debug bridge for iPhone / shell command prompt

可紊 提交于 2021-02-07 12:24:59
问题 For Android there is ADB (Android debug bridge) which allows to get a shell on the connected device: adb shell Is there something similar for iOS? I'd like to type some shell commands on my Mac that would be executed on the connected iPhone. Is there a built-in Terminal on iPhone? 回答1: There isn't anything for it built in, but if you are jailbroken or can sideload apps (a.k.a., you have a mac with XCode), you can run a local terminal with apps like MobileTerminal, which aren't available on

Why do bash command line arguments after 9 require curly brackets?

回眸只為那壹抹淺笑 提交于 2021-02-07 11:57:15
问题 This may not be the most thought provoking question, but nevertheless has struck my curiosity. I have not been able to come across any answer (let alone a definitive one) on the web. While reading Advanced Shell Scripting, I came across this section regarding command line positional arguments which states that anything after the the ninth argument must be surrounded by ${} (the longer form of variable referencing/substitution). Simply put, why must you reference command line argument ten (and

What is the difference between “else if” and “elif” in bash?

ぐ巨炮叔叔 提交于 2021-02-07 11:13:57
问题 I've got the following shell script that's supposed to simply stage a few Java .ear/.war files to JBoss: SUCCESS=false DEPLOY_PATH=/apps/jboss/server/default/deploy E_NOARGS=75 M_USAGE="usage: $0 {rcm|hcm}" M_MISSING_RCM="missing: rcm.war file not present" M_MISSING_HCM="missing: hcm.ear or hcm.war file not present" if [ -z "$1" ] then echo $M_USAGE exit $E_NOARGS else M_START="deploying $1 ..." M_FINISH="finished deploying $1" fi until [ -z "$1" ] do echo $M_START case "$1" in rcm*) # do a

sort a file based on a column in another file

大憨熊 提交于 2021-02-07 08:46:12
问题 I have two files both in the format of: loc1 num1 num2 loc2 num3 num4 The first column is the location and I want to use the order of the locations in the first file to sort the second file so that I can put the two files together where the numbers are right for the location. I can write a perl script to do this but I felt there might be some quick/easy shell/awk command to achieve this. Do you have any ideas? Thanks. Edits: Here is the input, now I actually want to use column 2 in file 1 to

sort a file based on a column in another file

試著忘記壹切 提交于 2021-02-07 08:45:25
问题 I have two files both in the format of: loc1 num1 num2 loc2 num3 num4 The first column is the location and I want to use the order of the locations in the first file to sort the second file so that I can put the two files together where the numbers are right for the location. I can write a perl script to do this but I felt there might be some quick/easy shell/awk command to achieve this. Do you have any ideas? Thanks. Edits: Here is the input, now I actually want to use column 2 in file 1 to

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