zoukankan      html  css  js  c++  java
  • linux 操作指南

    1. 删除 tmp2文本中所有的空格,将结果保存到tmp3中

    sed -r 's/s+//g' tmp2.txt > tmp3.txt

    2. 删除mp2文本中所有的空白行,将结果保存到tmp3中

    sed '/^[[:space:]]*$/d' tmp2.txt > tmp3.txt

     3. 在命令后接&(known as ampersand)让命令在后台运行

    This is known as job control under unix. The & informs the shell to put the command in the background. This means it continues to run the sys-snap.sh command but returns you to your shell to allows you to continue doing parallel commands.

    You can see the list of jobs presently running with the jobs command. You can return to the command (bring to the 'foreground) with use of the fg command. Which pulls the command back to the state where you see no prompt and you have to issue Ctrl-C to kill the process. You can however suspend (pause) that process, issuing Ctrl-Z. This will pause sys-snap.sh and return you to your prompt. You can then background it (as though you had issued it with the &) with the bg command, and it will resume running from it's paused state the Ctrl-Z had put it in.

    Note that you can have more than one job at a time (as shown by jobs):

    [1]-  Running          sys-snap.sh &
    [2]+  Running          another-script.sh &

    You can background and foreground them using their job number, %1 will be sys-snap.sh and %2 will be another-script.sh. If you use fg or bg without arguments it will action the command on the job marked by + in the jobs output above.

    fg %1

    will put sys-snap.sh back into the foreground, whilst leaving another-script.sh in the background.

    You can issue the Ctrl-C sequence to running jobs without having to foreground them with the kill command, kill %1 will send the equivalent of Ctrl-C to sys-snap.sh.

    If you are using bash shell, the man bash command has a detailed section under the section headed 'JOB CONTROL' going into more detail.

    As to the name of sys-snap.sh, under unix file names are arbitrary (with a couple of exceptions like dynamic loader files). There is no requirement for them to have specific file extentions to make them run as a shell script, invoke other commands such as perl or php etc. It is usually used to provide clarity, that in this instance, it is .sh a Shell Script using the Bourne Shell /bin/sh.

    The functional part of sys-snap.sh (when you look at it's contents with something like the less command) is the Shebang. On the first line you will probably find one of:

    #! /bin/sh
    #! /bin/bash
    #! /usr/local/bin/bash

    or similar. In basic terms, a the command after the #! (such as /bin/sh) is ran and the contents of the rest of the script file is fed to it a line at a time. Note that the file must also be set executable with chmod so that you can run it as a command. If the permissions were not set, then the shebang has no effect, because you would either get the error:

    bash: sys-snap.sh: command not found

    or if you ran it by explicit path ./sys-snap.sh (. meaning the current working directory) you would get:

    bash: ./sys-snap.sh: Permission denied

    The other alternative is to leave it without execute permissions and explicitly ask /bin/sh to run it:

    /bin/sh sys-snap.sh &

    如想要在后台运行redis服务,使用

    1 redis-server &

    这样redis服务就会转到后台运行,终端可以继续接收其他命令。在运行了后台服务的终端(重开一个终端看不到本终端的后台服务)上,

    • 使用 jobs 命令可以查看后台服务列表。
    • 使用 fg 命令可以将后台切换回前台
    • 在后台服务切换回前台后,按下 ctrl+z 可以挂起前台服务,接收其他命令;
    • 再使用 bg 命令可以将该服务继续放到后台执行
    • 如果有多个后台服务, 使用 fg %1 会将第一个后台服务切换回前台,以此类推。fg 默认会将 jobs 服务列表上带“+”的服务切换回前台
    TALK IS CHEAP, SHOW ME THE CODE
  • 相关阅读:
    删除ubuntu自带软件 及 WPS 安装(转)WPS字体已备份
    youtube-dl 下载爱奇异视频 不能删除
    電影嘗試三 webtorrent-desktop在線觀看電影magnet
    wget 命令
    什么是X window
    查看磁盘分区
    root
    错误:org.hibernate.exception.GenericJDBCException: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA ....
    Git 版本回退
    oracle密码过期问题解决
  • 原文地址:https://www.cnblogs.com/greatLong/p/11643996.html
Copyright © 2011-2022 走看看