zoukankan      html  css  js  c++  java
  • shell基础二十篇 一些笔记

    shell基础二十篇

    转自 http://bbs.chinaunix.net/thread-452942-1-1.html

     研讨:Bash 内建命令 read

    (read命令更具体的说明见博客收藏的一篇:http://www.cnblogs.com/xiangzi888/archive/2012/03/27/2420084.html)

    read -p "how old r u? " age
    echo $age
    read -p "some words? " -a words
    echo ${words[*]}
    read -p "Password: " -s passwd
    echo $passwd
    read -t 5 auth
    echo $auth
    read -n 1 key
    read -dq -p "input something end with q: " menu
    read -e file #在这试试命令历史和补齐功能

    我认为read ?很好用,比echo "input:";read input...用简便!像这样:
    read input?"input:"
    echo $input

    而且read a b c这样用也很实用:
    echo -n "please year month day"
    read a b c
    echo $a $b $c

    另外就是read读fd,比如常用的两个文件的拼接:
    while read -u3 i && read -u4 j;do
    echo $i $j
    done 3<afile 4<bfile

    sed '1,3d' quote.txt  删除1-3行。

    sed '/Neave/d' quote.txt  删除所有包含Neave的行。

    sed 's/splendid/SPLENDID/w sed.out' quote.txt    替换并将结果写到文件sed.out中。

  • 相关阅读:
    进程与线程的区别
    信号列表详解
    同步与互斥
    互斥锁
    读写锁
    Redis QPS测试
    从分布式锁来看redis和zookpeer!
    JVM虚拟机调参
    log4j.properties配置详解与实例
    生产者消费者(消费者要消费完才能退出)
  • 原文地址:https://www.cnblogs.com/ph829/p/4648117.html
Copyright © 2011-2022 走看看