小编Chr*_*s W的帖子

脚本中带空格的文件名

这是一个简单的脚本,用于将文件路径传递给lsorchmod但即使用引号括起来,带空格的文件名也不起作用。

我如何让它工作?

#!/bin/sh
# Script to fix permissions on supplied folder and file name

echo "Enter Folder name"
read folder
echo "Folder name is "$folder
echo "Enter File name - if name includes spaces enclose in single quote marks"
read filename 

echo "File name is "$filename
fullpath="/home/abc/"$folder"/"$filename

echo "Full path is "$fullpath

fixcommand="chmod a+rw -v "$fullpath

echo "Command to be executed is "$fixcommand

echo -n "Is that correct (y/n)? "
read answer
if echo "$answer" | …
Run Code Online (Sandbox Code Playgroud)

bash scripts

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

bash ×1

scripts ×1