相关疑难解决方法(0)

shell 的控制和重定向操作符是什么?

我经常在网上看到用不同符号连接各种命令的教程。例如:

command1 |  command2
command1 &  command2
command1 || command2    
command1 && command2
Run Code Online (Sandbox Code Playgroud)

其他人似乎将命令连接到文件:

command1  > file1
command1  >> file1
Run Code Online (Sandbox Code Playgroud)

这些是什么?他们叫什么?他们在做什么?还有更多吗?


关于这个问题的元线程。.

shell io-redirection control-flow

353
推荐指数
3
解决办法
17万
查看次数

重定向到 /dev/null

我正在阅读一个示例 bash shell 脚本:

#!/bin/bash

# This script makes a backup of my home directory.

cd /home

# This creates the archive
tar cf /var/tmp/home_franky.tar franky > /dev/null 2>&1

# First remove the old bzip2 file.  Redirect errors because this generates some if the archive
# does not exist.  Then create a new compressed file.
rm /var/tmp/home_franky.tar.bz2 2> /dev/null
bzip2 /var/tmp/home_franky.tar

# Copy the file to another host - we have ssh keys for making this work without intervention.
scp …
Run Code Online (Sandbox Code Playgroud)

shell-script null

227
推荐指数
4
解决办法
54万
查看次数

标签 统计

control-flow ×1

io-redirection ×1

null ×1

shell ×1

shell-script ×1