linux shell脚本在当前文件夹中运行可执行文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5405831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:22:36  来源:igfitidea点击:

linux shell script to run an executable file in current folder

linuxbashsh

提问by Inuart

I have an executable file always in /home/acalled toUpperCase.

我总是在/home/a 中有一个名为toUpperCase的可执行文件。

Now I am in the folder /home/bla/blabla/bwhere I have a text file to be converted to uppercase (toConvert.txt). All I want to do is a script that executed in /home/bla/blabla/bdoes something like

现在我在文件夹/home/bla/blabla/b 中,我有一个文本文件要转换为大写(toConvert.txt)。我想要做的就是在/home/bla/blabla/b中执行的脚本执行类似的操作

#!/bin/bash
./"/home/a/toUpperCase" toConvert.txt

So in the end I shoud have converted.txtin the folder /home/bla/blabla/b

所以最后我应该在文件夹/home/bla/blabla/b 中转换.txt

But it gives me an error like line 2: .//home/a/toUpperCase: does not exist

但它给了我一个错误 line 2: .//home/a/toUpperCase: does not exist

How con I resolve this problem? thank you!

我如何解决这个问题?谢谢你!

采纳答案by Sylvain Defresne

Change your script to:

将您的脚本更改为:

#!/bin/bash
"/home/a/toUpperCase" toConvert.txt