How to determine if a file is empty in the shell

When writing scripts in Linux, there is always the need to determine whether the existence of files, the contents of the file is empty and so on, and these operations can be implemented with the test instructions, through the man test instructions

Various judgments of shell scripts

1. String judgment STR1 = str2 When two strings have the same content, the length is true STR1!= str2 is true when strings str1 and str2 are unequal -N str1 True when the length of the string is greater than 0 (string not empty) -Z str1 True when

shell+ Timing Task +nginx signal Management implementation log cut storage by date

We renamed yesterday's log 00:00:01 every day, placed it in a specific directory, and then USR1 the information number control Nginx to regenerate a new log file Create a new shell script under directory/usr/local/nginx/logs/runlog.shNote: The file

Crontab+shell Job Flow scheduling __hadoop

In the previous article, we had a simple reference to the pseudo code of the shell or Python dispatch hive, and today we are enriching the pseudocode http://blog.csdn.net/haohaixingyun/article/details/51821444 Note that in the actual production

Written question Shell

Enterprise Practice question 1: (Production actual case): monitor MySQL master-slave synchronization is abnormal, if abnormal, send sms or mail to the administrator. Note: If there is no master-slave synchronization environment, you can use the

Set IP address shell script

#!/bin/bashA="IPADDR.*"B="NETMASK.*"C="GATEWAY.*"D="DNS1.*"E="/etc/sysconfig/network-scripts/ifcfg-eth1"F="cat $E | sed -n ‘/BOOTP/p‘"if [ ! "$F" = "BOOTPROTO=dhcp" ] thenread -t 30 -p "Please enter the IP address:" IPread -t 30 -p "Please enter

Shell Installation glibc

#!/bin/bashnum=`cat /proc/cpuinfo | grep processor | wc -l`yum install wget gcccd /usr/local/src/wget -c http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gztar -xf glibc-2.14.tar.gz cd glibc-2.14 && mkdir build../configure --prefix=/usr --disable-profile

Linux enters the history command in the shell

In the Linux shell, often input commands have a lot of similarities, even the same, if the long command, the efficiency is really very low, but can be through ctl+r, find the history of the previous input commands, it is very useful.After pressing

Shell programming string comparisons and for loops

One, string comparison 字符串比较使用:= ,==,!=,\>,\ , \ ‘aa‘ 字符串是否为空判断: 如:- n string 判断字符串string是否为空,不为空返回真,-z string 判断字符串是否为空,为空返回真。Second, for Loop用法: for 变量名 in 列表 do 循环体 doneIii. Scripting Exercises1.

Shell Programming (2)

1. (1) Change the main prompt to the user's home directory name (hint: reference material 4.6.8 section environment variable PS1 and HOME usage)(2) Assign the string DOS file c:>\ $student \* to the variable x and display it (hint: note the choice

Shell Script Forloops

1. Determine the type of all files in the/var/directoryfor files in /var/* ;do if [[ -f $files ]];then echo "$files exists and is a regular file." elif [[ -h $files ]] ;then echo "$files is a symbolic link." elif [[ -d

Shell Learning (iii)

Libvirt Tools for managing the KVM itselfVirt-install installation packages for installing virtual machines, installing virtual machinesVirt-mananger: Managing a tool to create a delete virtual machine---restore content starts---1 Grep-e "SVM | VMX "

Day9-1 Shell Basics

The shell is a command interpreter that provides user and machine interaction before Command historyPress UP ARROW key to appear before order historyHistory View Previous commandsThe command history exists in the file. Bash_historyThe maximum

The meaning of $x in the shell

The execution name of this program$n the nth parameter value of this program, n=1..9$* all parameters of this program, this option can have more than 9 parameters.$# the number of parameters for this program$$ the PID of this program (the current

Script for Shell script to bulk modify file name suffix

Experimental material:[[email protected] test]# ls//This directory contains all the files ending in. txt and requires all to be replaced by the. Doc End1.txt 2.txt 3.txt 4.txt 5.txtWriting scripts[Email protected] test]# vim/root/25.shScript content:

First knowledge of the shell

A shell script is a special application that acts as a "command interpreter" between the operating system kernel and the user, takes care of the user input commands and interprets them, passes the required actions to the kernel execution, and

Shell script Note (ii) Shell variables

Shell variable one) Global environment variablesA global variable is visible to both the shell that defines it and its child shell, but if the shell that generates it is terminated, the global variable disappears. In addition, the global variables

Shell Pass Parameters

We can pass parameters to the script when executing the Shell script, and the format of the parameters obtained in the script is:$n. n represents a number, 1 is the first argument to execute the script, 2 is the second argument to execute the script,

Linux Shell Tutorials

Shell TutorialsShell is a C language program, he is a user using Linux bridge, Shell is both a command language, but also a programming language.The Shell refers to an application that provides an interface through which users access the operating

Use shell to generate xml in simple format

The following is the shell code: Create_xml.sh #! /Bin/bash # Author: dengzhaoqun # Date: 201202/14 OUTFILE = outtabs = 0put () {echo ' $ OUTFILE} put_head () {put '? '$ {1 }'? '} Out_tabs () {TMP = 0 tabsstr = "" While [$ TMP-lt $ (tabs)]

Total Pages: 541 1 .... 487 488 489 490 491 .... 541 Go to: GO

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.