我有一个字符串:
AddData
TestSomething
TellMeWhoYouAre
Run Code Online (Sandbox Code Playgroud)
等等。我想在大写字母前添加空格。我该怎么做?
例如,我需要监视文件/tmp/somefile123是否是在某些事件之后创建的。我尝试使用inotifywait但这里有一个问题:
# inotifywait -q -e create /tmp/somefile?*
Couldn't watch /tmp/somefile?*: No such file or directory
Run Code Online (Sandbox Code Playgroud)
因为完全没有这样的文件,我想知道它是否会在那里!
我该如何解决这个问题?
UPD:也许如果我解释一下我想要达到的目标会更清楚。
我需要以最少的 CPU 消耗编写 shell 脚本 (sh),如下所示:
if [ $(inotifywait -e create $SPECIFIC_FILE) ]; then
blah-blah-blah some actions
fi
# And then similarly monitor if this file was deleted and then do another actions
Run Code Online (Sandbox Code Playgroud)
我希望脚本会在inotifywait -e create $SPECIFIC_FILE上停止执行,直到这个 $SPECIFIC_FILE 不会被创建,然后会更好
while [ ! -f $SPECIFIC_FILE ]; do
blah-blah-blah some actions
sleep 1
done
Run Code Online (Sandbox Code Playgroud)