Shell 重命名文件的脚本 - Shell 脚本
Shell script for rename the file - Shell script
我完全不熟悉 shell 脚本,但我需要编写一个 shell 脚本来检查文件是否存在,然后移动到另一个位置
这是我写的:
一旦设备崩溃,我就会在 /storage/sdcard1/1
中收集日志
#!/system/bin/sh
if [ -d /storage/sdcard1/1 ]; then
mkdir crash1
mv 1 crash1
fi
无论何时找到 /storage/sdcard1/1 目录,我们都必须分别将其重命名为 crash1,crash2,crash3
。
我无法理解其中的逻辑。谁能帮我吗?
target=/home/john/data
if [ -d /storage/sdcard1/1 ]; then
mv /storage/sdcard1/1 $target/crash1
fi
把目标设置到你想去的地方"crash1"
用 2 和 3 代替 1
重复代码
大多数人会使用变量和循环来执行 1、2、3,但让我们保持简单
我完全不熟悉 shell 脚本,但我需要编写一个 shell 脚本来检查文件是否存在,然后移动到另一个位置
这是我写的:
一旦设备崩溃,我就会在 /storage/sdcard1/1
中收集日志#!/system/bin/sh
if [ -d /storage/sdcard1/1 ]; then
mkdir crash1
mv 1 crash1
fi
无论何时找到 /storage/sdcard1/1 目录,我们都必须分别将其重命名为 crash1,crash2,crash3
。
我无法理解其中的逻辑。谁能帮我吗?
target=/home/john/data
if [ -d /storage/sdcard1/1 ]; then
mv /storage/sdcard1/1 $target/crash1
fi
把目标设置到你想去的地方"crash1" 用 2 和 3 代替 1
重复代码大多数人会使用变量和循环来执行 1、2、3,但让我们保持简单