我有一个脚本/etc/init.d,我试图将echo语句添加到...但我的所有更改似乎都被忽略了。
我猜是因为脚本本身实际上并没有运行,而是systemd在幕后做一些事情来继续运行旧版本的脚本。有没有办法“加载”这些更改?
我想创建一个可以处理参数 ( $1)的别名,如果没有提供参数,可以回退到默认值。例如,
$ alias foo='NUM=${1:-42}; echo $NUM'
Run Code Online (Sandbox Code Playgroud)
在没有参数的情况下调用它可以按我的意愿工作:
$ foo
42
Run Code Online (Sandbox Code Playgroud)
但是使用参数调用时,它会打印我的值和默认值:
$ foo 69
42 69
Run Code Online (Sandbox Code Playgroud)
我不明白为什么会这样。应该如何正确操作?我怎样才能自己调试这种问题?
我想从内核打印一些语句,但不是全部。
那么我可以有选择地使用printk吗?
有选择地我的意思是我只想在特定的地方启用 printk 而在其他地方禁用它。
现在我只能启用(在内核配置中启用printk)或全局禁用它;我根本别无选择。
当我执行 tar 命令时,例如:
tar -xzvf xxxxxxxx
tar -zcvf xxxxxxxx
Run Code Online (Sandbox Code Playgroud)
该-v参数会降低操作的性能还是可以忽略不计?
我发现跟踪繁重操作的进度很有用,但我想知道是否可以保留它。
Linux Mint 上的 Bash 4.3 shell:
我意识到 Bash shell 是无类型的,或者具有非常弱的打字形式。但是,是否可以调用 Bash shell(例如使用某些选项),以便当声明的整数变量被滥用(例如,通过尝试将字符串存储到该整数变量中)时,shell 将抛出运行时错误?
示例代码:
declare -i age
age=23
echo "$age" # result is 23
age="hello"
echo "$age" # result is not the string hello - wish I could get an error message here!```
Run Code Online (Sandbox Code Playgroud) debugging ×5
alias ×1
bash ×1
init-script ×1
linux-kernel ×1
shell ×1
shell-script ×1
systemd ×1
tar ×1