Merge pull request #4759 from geekpi/master

translated
This commit is contained in:
geekpi 2016-12-16 10:53:59 +08:00 committed by GitHub
commit b49ded9b33
4 changed files with 166 additions and 168 deletions

View File

@ -1,89 +0,0 @@
translating---geekpi
How to Copy a File to Multiple Directories in Linux
============================================================
[While learning Linux][1], it is always the norm for newbies to keep on typing several commands to accomplish a simple task. This is understandable especially when one is just getting accustomed to using the terminal.
However, as you look forward to becoming a Linux power user, learning what I would refer to as “shortcut commands” can significantly reduce time wasting tendencies.
In this article, we will explain an easy way, using a single command to copy a file into multiple directories in Linux.
In Linux, the [cp command][2] is used to copy files from one directory to another, the easiest syntax for using it is as follows:
```
# cp [options….] source(s) destination
```
Alternatively, you can also use the [advanced-copy command][3], which shows a progress bar while copying [large files/folders in Linux][4].
Consider the commands below, normally, you would type two different commands to copy the same file into two separate directories as follows:
```
# cp -v /home/aaronkilik/bin/sys_info.sh /home/aaronkilik/test
# cp -v /home/aaronkilik/bin/sys_info.sh /home/aaronkilik/tmp
```
[
![Copy Files to Multiple Directories](http://www.tecmint.com/wp-content/uploads/2016/12/Copy-Files-to-Multiple-Directories.png)
][5]
Copy Files to Multiple Directories
Assuming that you want to copy a particular file into up to five or more directories, this means you would have to type five or more cp commands?
To do away with this problem, you can employ the [echo command][6], a pipe, xargs command together with the cpcommand in the form below:
```
# echo /home/aaronkilik/test/ /home/aaronkilik/tmp | xargs -n 1 cp -v /home/aaronkilik/bin/sys_info.sh
```
In the form above, the paths to the directories (dir1,dir2,dir3…..dirN) are echoed and piped as input to the xargscommand where:
1. `-n 1`  tells xargs to use at most one argument per command line and send to the cp command.
2. `cp`  used to copying a file.
3. `-v`  enables verbose mode to show details of the copy operation.
[
![Copy File to Multiple Locations in Linux](http://www.tecmint.com/wp-content/uploads/2016/12/Copy-Files-to-Multiple-Directories-in-Linux.png)
][7]
Copy File to Multiple Locations in Linux
Try to read through the man pages of `cp`, `echo` and `xargs` commands to find useful and advanced usage information:
```
$ man cp
$ man echo
$ man xargs
```
Thats all, you can send us questions in relation to the topic or any feedback through the comment form below. You may also want to read about the [progress command][8] which helps to monitor the progress of (cp, mv, dd, [tar][9], etc.) commands that are presently running in Linux.
--------------------------------------------------------------------------------
作者简介:
![](http://1.gravatar.com/avatar/4e444ab611c7b8c7bcb76e58d2e82ae0?s=128&d=blank&r=g)
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/copy-file-to-multiple-directories-in-linux/
作者:[Aaron Kili][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/aaronkili/
[1]:http://www.tecmint.com/free-online-linux-learning-guide-for-beginners/
[2]:http://www.tecmint.com/advanced-copy-command-shows-progress-bar-while-copying-files/
[3]:http://www.tecmint.com/advanced-copy-command-shows-progress-bar-while-copying-files/
[4]:http://www.tecmint.com/find-top-large-directories-and-files-sizes-in-linux/
[5]:http://www.tecmint.com/wp-content/uploads/2016/12/Copy-Files-to-Multiple-Directories.png
[6]:http://www.tecmint.com/echo-command-in-linux/
[7]:http://www.tecmint.com/wp-content/uploads/2016/12/Copy-Files-to-Multiple-Directories-in-Linux.png
[8]:http://www.tecmint.com/progress-monitor-check-progress-of-linux-commands/
[9]:http://www.tecmint.com/18-tar-command-examples-in-linux/

View File

@ -1,79 +0,0 @@
Add Rainbow Colors to Linux Command Output in Slow Motion
============================================================
In this article, we will review a cool and simple way of giving a command screen output a rainbow colors and slowing down its output speed as well for one reason or the other.
The [lolcat program][2] is used for the above purpose. It basically functions by concatenating files, or standard input, to standard output in a similar way as the [cat command][3], overrides the default screen output color of a particular command and adds rainbow coloring to it.
### How to Install Lolcat Program in Linux
Lolcat program is available on almost all modern Linux distributions from its default repository, but the available version bit older. Alternatively you can install latest version of lolcat from git repository using this following guide.
1. [Install Lolcat to Output Rainbow Of Colors in Linux Terminal][1]
Once lolcat installed, the basic syntax for running lolcat is:
```
$ lolcat [options] [files] ...
```
It comes with several options that control its behavior, below are a few of the most considerable flags we will emphasis for the scope of this guide:
1. `-a`  passes every input line through an animation effect.
2. `-d`  specifies the duration (number of steps before displaying next line) of the animation effect, the default value is 12.
3. `-s`  it specifies the speed (frame rate- number of steps per second) of the animation effect, default value is 20.
4. `-f`  enables forcing of coloring in case standard output is not a tty.
You can find more options in the lolcat man page:
```
$ man lolcat
```
### How to Use Lolcat in Linux
To use lolcat, simply pipe the output of any relevant command to it and watch the magic.
For example:
```
$ ls -l | lolcat -as 25
```
[
![colorful Linux Terminal Output](http://www.tecmint.com/wp-content/uploads/2016/12/Colorful-Linux-Terminal-Output.gif)
][4]
Besides you can alter the default speed, in the following command, we will use a relatively slow speed of 10steps per second:
```
$ ls -l | lolcat -as 10
```
You can use any command with lolcat display output in colorful fashion on Linux terminal, few commands say ps, date and cal as:
```
$ ps | lolcat
$ date | lolcat
$ cal | lolcat
```
In this article, we have looked at how to significantly reduce the speed of a command screen output and give it a rainbow coloring effect.
As usual, you can address to us any questions or comments concerning this article via the feedback section below. Lastly, you can mention to us any useful Linux commands you have discovered there.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/add-colors-to-command-output-terminal-linux/
作者:[ Aaron Kili ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/aaronkili/
[1]:http://www.tecmint.com/lolcat-command-to-output-rainbow-of-colors-in-linux-terminal/
[2]:http://www.tecmint.com/lolcat-command-to-output-rainbow-of-colors-in-linux-terminal/
[3]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
[4]:http://www.tecmint.com/wp-content/uploads/2016/12/Colorful-Linux-Terminal-Output.gif

View File

@ -0,0 +1,87 @@
如何在Linux中复制文件到多个目录中
============================================================
[在使用Linux中][1],对于新手而言总是会使用几个命令来完成一个简单的任务。对正在熟悉使用终端的人这是很容易理解的行为。
然而,如果你想要成为一个老手,学习我说的“快捷命令”会显著减少时间浪费。
在本篇中我们会用一个简单的方法在Linux中用一个命令来将目录复制到多个文件夹中。
在Linux中[cp命令][2]长被用于从一个文件夹中复制文件到另一个中,最简单的语法如下:
```
# cp [options….] source(s) destination
```
另外,你也可以使用[一个高级复制命令][3],它可以在复制[大的文件或文件夹中][4]显示进度条。
看下下面的命令,通常你会使用两个不同的命令拉将相同的文件复制到不同的文件夹中:
```
# cp -v /home/aaronkilik/bin/sys_info.sh /home/aaronkilik/test
# cp -v /home/aaronkilik/bin/sys_info.sh /home/aaronkilik/tmp
```
[
![Copy Files to Multiple Directories](http://www.tecmint.com/wp-content/uploads/2016/12/Copy-Files-to-Multiple-Directories.png)
][5]
复制文件到多个文件夹中
假设你想要复制一个特定文件到5个或者更多的文件夹中这意味着你需要输入5次或者更多的cp命令
要摆脱这个问题你可以用cp命令与[echo命令][6]、管道、xargs命令一起使用
```
# echo /home/aaronkilik/test/ /home/aaronkilik/tmp | xargs -n 1 cp -v /home/aaronkilik/bin/sys_info.sh
```
上面的命令中目录的路径dir1、dir2、dir3...dirN)被管道作为输入到xargs命令中含义是
1. `-n 1` - 告诉每个命令最多使用一个参数并发送到cp命令中。
2. `cp`  用于复制文件。
3. `-v`  启用verbose模式来显示更多复制细节。
[
![Copy File to Multiple Locations in Linux](http://www.tecmint.com/wp-content/uploads/2016/12/Copy-Files-to-Multiple-Directories-in-Linux.png)
][7]
在Linux中复制文件到多个位置中
尝试阅读`cp`、 `echo` 和 `xargs`的man页面来找出所有有用和高级的用法信息
```
$ man cp
$ man echo
$ man xargs
```
就是这样了,你可以在下面的评论区给我们发送主题相关的问题或者反馈。你也可以阅读有关[progress命令][8]来帮助监控运行中的cp、mv、dd、[tar][9]等等)的进度。
--------------------------------------------------------------------------------
作者简介:
![](http://1.gravatar.com/avatar/4e444ab611c7b8c7bcb76e58d2e82ae0?s=128&d=blank&r=g)
Aaron Kili是一个Linux及F.O.S.S热衷者即将是Linux系统管理员、web开发者目前是TecMint的内容创作者他喜欢用电脑工作并坚信分享知识。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/copy-file-to-multiple-directories-in-linux/
作者:[Aaron Kili][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/aaronkili/
[1]:http://www.tecmint.com/free-online-linux-learning-guide-for-beginners/
[2]:http://www.tecmint.com/advanced-copy-command-shows-progress-bar-while-copying-files/
[3]:http://www.tecmint.com/advanced-copy-command-shows-progress-bar-while-copying-files/
[4]:http://www.tecmint.com/find-top-large-directories-and-files-sizes-in-linux/
[5]:http://www.tecmint.com/wp-content/uploads/2016/12/Copy-Files-to-Multiple-Directories.png
[6]:http://www.tecmint.com/echo-command-in-linux/
[7]:http://www.tecmint.com/wp-content/uploads/2016/12/Copy-Files-to-Multiple-Directories-in-Linux.png
[8]:http://www.tecmint.com/progress-monitor-check-progress-of-linux-commands/
[9]:http://www.tecmint.com/18-tar-command-examples-in-linux/

View File

@ -0,0 +1,79 @@
缓慢输出Linux命令并用彩色显示
============================================================
本篇中,我们会展示一个很酷及简单的方法在屏幕中显示彩色的输出,并且可以为了某个原因减慢输出的速度。
[lolcat命令][2]可以满足上面的需求。它基本上通过与[cat命令][3]类似的方式将文件或标准输入定向到标准输出来运行,覆盖特定命令的默认屏幕输出颜色,并为其添加彩色。
### 如何在Linux中安装lolcat程序
lolcat可以在大多数现在Linux发型版的默认仓库中得到但是可用的版本有点老。你可以使用下面的指导来从git仓库中安装最新的lolcat版本。
1. [安装lolcat来在Linux中显示彩色输出][1]
lolcat安装后基本的lolcat语法是
```
$ lolcat [options] [files] ...
```
有几个选项可以控制它的行为,下面是一些我们在本指导中会强调的几个最重要的标志:
1. `-a` - 将每行输出都显示动态效果。
2. `-d`  指定动画效果间隔显示下一行之前的帧默认是12。
3. `-s`  它指定了动画效果的速度(帧速-每秒的帧默认是20。
4. `-f`  强制显示彩色防止标准输出不是tty。
你可以在lolcat的man页可以找到更多的选项
```
$ man lolcat
```
### 如何在Linux中使用lolcat
要使用lolcat直接将相关命令的输出通过管道给lolcat接着见证魔法。
比如:
```
$ ls -l | lolcat -as 25
```
[
![colorful Linux Terminal Output](http://www.tecmint.com/wp-content/uploads/2016/12/Colorful-Linux-Terminal-Output.gif)
][4]
除此之外你可以改变默认速度在下面的命令中我们会使用一个相对较慢的速度每秒显示10帧
```
$ ls -l | lolcat -as 10
```
你可以使用任何命令结合lolcat在Linux终端中输出彩色结果比如ps、date和cal
```
$ ps | lolcat
$ date | lolcat
$ cal | lolcat
```
本篇中,我们了解了如何显著减小屏幕输出的速度,并显示彩色效果。
通常上,你可以在下面的评论栏中留下任何关于本篇的问题或评论。最后,你可以留下任何你发现的有用命令。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/add-colors-to-command-output-terminal-linux/
作者:[ Aaron Kili ][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/aaronkili/
[1]:http://www.tecmint.com/lolcat-command-to-output-rainbow-of-colors-in-linux-terminal/
[2]:http://www.tecmint.com/lolcat-command-to-output-rainbow-of-colors-in-linux-terminal/
[3]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
[4]:http://www.tecmint.com/wp-content/uploads/2016/12/Colorful-Linux-Terminal-Output.gif