技术开发 频道

闻所未闻 10个你不曾用过的Linux命令

  3、bc 是个任意精度计算器语言,它可以Shell脚本执行平方根操作,expr 不支持平方根。

  # ./sqrt
  Usage: sqrt number
  # .
/sqrt 64
  
8
  # .
/sqrt 132112
  
363
  # .
/sqrt 1321121321
  
36347
  Here is the script:
  # cat sqrt
  #
!/bin/bash
  
if [ $# -ne 1 ]
  then
  echo
'Usage: sqrt number'
  exit
1
  
else
  echo
-e "sqrt($1)\nquit\n" | bc -q -i
  fi

  4、split, 你需要将大的文件分解称若干小部分?split是你的命令,下面是将250MB文件分解为2M的块儿,所有开始于LF_前缀。

  # ls -lh largefile
  
-rw-r--r-- 1 root root 251M Feb 19 10:27 largefile
  # split
-b 2m largefile LF_
  # ls
-lh LF_* | head -n 5
  
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_aa
  
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ab
  
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ac
  
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ad
  
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ae
  # ls
-lh LF_* | wc -l
  
126

  5、nl 数字线,在没发现nl之前,一直用脚本来实现。

# head wireless.h
/*
* This file define a set of standard wireless extensions
*
* Version : 20 17.2.06
*
* Authors : Jean Tourrilhes - HPL
* Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
*/#ifndef _LINUX_WIRELESS_H
# nl wireless.h
| head
1 /*
2 * This file define a set of standard wireless extensions
3 *
4 * Version : 20 17.2.06
5 *
6 * Authors : Jean Tourrilhes - HPL
7 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
8
*/9 #ifndef _LINUX_WIRELESS_H
0
相关文章