gpt4 book ai didi

linux - 如何在 Linux 中创建可复制和粘贴文件的可执行文件(.sh)

转载 作者:太空宇宙 更新时间:2023-11-04 06:03:55 25 4
gpt4 key购买 nike

如何创建可复制和粘贴文件的 .sh 文件?

我使用以下代码创建了一个 script.sh 文件:

#!/bin/sh
tar -pzvxf file1.tar (to unzip)
cp -a /root/Desktop/file1/. /root/Desktop/Destination (copy)

之后我./script.sh运行它,但它无法运行。知道为什么吗?

最佳答案

确保脚本设置了可执行位。尝试在您的 shell 中使用它。

chmod +x ./script.sh

这将确保脚本可以由您的 shell 执行。

关于linux - 如何在 Linux 中创建可复制和粘贴文件的可执行文件(.sh),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53275874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com