The writing of Linux shell scripts
VI test.sh
#!/bin/bash
###################
. /etc/profile
. ~/.bash_profile
##################
Path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Cd/home/huaxia/syslog2db&&ruby app.rb
believe that the progress bar everyone is not unfamiliar, every time you download something or software will be prompted by the current download task to achieve how much, of course, can have different languages to achieve, today I use a shell script
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
#!/bin/bash function ergodic () {for file in ' ls ' if [D-$ '/' $file] then ergodic '/' $file else echo '/' $file >> b fi Done} init_path= "/etc/httpd" ergodic $INIT _path
Some netizens replied: "If you only traverse the directory and create an
Today see the system space is occupied, and then look at large files, found that Catalina.out has been >60g, there are many solutions online, but still want to learn to write a shell script to deal with, in this record to write content, as well as
-CP and-classpath Specify the paths of other classes that the class runs on, usually the class library, the jar pack, and so on
Windows semicolon ";" separated by semicolons on Linux: "Delimited." Use a little "." Represents the current path
SET Command
The set command acts primarily to display shell variables that already exist in the system, and to set new variable values for shell variables. When you use set to change shell attributes, the function of the symbol "+" and "-" is to
First line:
the first line of #!/bin/bash-e indicates that the following script is processed with bash syntax. Because most Linux defaults to bash, you can not write this line.
The parameter-e indicates that once an error occurs, the current shell
Reproduced from: http://blog.csdn.net/askbai666888/article/details/9995837
(1) tree-a display all files and directories
(2) tree-d display directory name rather than content
(3) Tree-f displays the full relative path name before each file or
Cut-and
The Cut command extracts text columns from a text file or text stream.
Cut syntax
[root@www ~]# cut-d ' delimited character '-f fields
The PATH variable is as follows
[Root@www ~]# echo $PATH
/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/
Everyone must know how to get the sed into the shell variable
However, there is a problem with passing in the path variable.
#!/bin/bash
export vob=/home/fesu/server
sed-n '/^vob/{s/\ (vob=\). */\1 ' "$VOB" '/P} ' $VOB/scripts/build/ Makefile
File expression
-e filename true if filename exists
-d filename If filename is a directory, true
-F filename True if filename is a regular file
-L filename True if filename is a symbolic link
-r filename If filename is readable, true
-W filename if
First Master:
Parameters:
Run the HBase shell
hbase Shell Parameters
the shell that runs up after HBase
Try to run a few orders to find out:
Create ' T_person ', ' no ', ' name '
create ' t_person ', ' no ', ' name '
0 row (s) in 2.
Rules:
a--number pair, position is right
b--The result of a, the number is correct, but the position is incorrect.
After starting, a systematic initialization of a 4-bit repeatable number, such as "1223". Assuming that the user enters "1234" for the
Checkpid: Check if PID already exists, if one exists, return 0 (by viewing the/proc directory)Daemon: Start ServiceKillproc: Kill a processPidfileofproc: Finding the PID of a processPidofproc: Ditto, use the PIDOF commandStatus: Returns the state of
-B file if it exists and is a block special file, True-C file If it exists and is a character special file, True-D file if it exists and is a directory, true-e File is true if it exists-F file is true if it exists and is a rule file-G file is true
First, position variables:
$ $ Gets the file name of the current execution script, including the script path.$n gets the nth parameter of the current execution script, 1~9, greater than 9, enclosed in {}, for example: ${10}.$# indicates the number
1. Command-line parameters------similar to javac parameter 1 parameter 2Java-like compiled Javac parm1 ..... In the shell, the arguments are separated from the arguments by a space. Use positional parameters to identify corresponding parameter
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
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