Shell trivia (Occasional updates)

Source: Internet
Author: User

# # #判断linux系统是32位还是64位

You can use "getconf word_bit" and "getconf long_bit" to get the digits of WORD and LONG, and 64-bit systems should be 32 and 64 respectively.

If [$ (getconf word_bit) = ' + '] && [$ (getconf long_bit) = ' 64 ']; Then
Echo 64
Else
Echo 32
Fi



# # #在当前脚本中调用另外的脚本文件

Method: (English point). + file name or source + file name

Fist.sh:

#!/bin/bash
Echo ' Your is in first file '

Second.sh:

#!/bin/bash
Echo ' Your is in second file '
SOURCE First
#或者用下面的方法



# # #列出当前目录下最大的10个文件

[Email protected] ~]# Du-s * | Sort-n | Tail



# # #统计keyword在日志中的出现次数

[Email protected] test]# grep-c ". Net" Resolve.txt 28


###!$

!$ is a special environment variable that represents the last string of the previous command. Such as: You may be like this:

$mkdir Mydir

$MV Mydir Yourdir

$CD Yourdir

Can be changed to:

$mkdir Mydir

$MV!$ Yourdir

$CD!$

Sudo!!

Execute the previous command as root



# # #shell时间

2 days before Time:

[[email protected] test]# date-d "2 days ago" +%y-%m-%d 2015-02-03

1 days before Time:

date-d "Yesterday" +%y-%m-%d

date-d "1 days Ago" +%y-%m-%d


Current time:

[[Email protected] test]# Date ' +%y-%m-%d%h:%m:%s ' 2015-02-05 04:19:02


Shell trivia (Occasional updates)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.