First, the grammar while [Condition] # when the condition condition is established, loop until the condition is not set to stop doing #执行内容done Second, practice
Enter the user input parameters until the user enters "end" to end the loop
Linux shell scripting:1. Program Structure Exercise: Write a script, given a positive integer, to calculate the sum of all digits of this number.For example, if the program is given input 123, it should return 1+2+3=6.2. Program Structure Exercise:
1. Questions: in the afternoon, a classmate asked such a question: Tail-n +$ (tail-n1/root/tmp/n)-f/root/tmp/ip.txt 2>&1| awk ' argind==1{i=$0;next}{i++;if ($0~/file truncated/) {i=0};p rint "---" I;print i >> "/root/tmp/n"} '/root/tmp/n- Seq
The du command can view the number of tiles occupied by the specified folder, and the following is the code for the C language implementation of the Shell du Directive under Linux (Support-k option):#include #include #include #include #include
Idea: (1) get "." The I node number, which is called N (using stat)(2) ChDir. (using ChDir)(3) Find the node with inode number n and get its file name.Repeat the operation until the current directory "." The inode value equals "..." The Inode
#! /bin/shLook for Shell interpreter/bin/sh is a path#! /usr/bin/pythonJust looking for a Python interpreter.How to run a Linux program:Allow files to run directly with executable permissionsInvoke interpreter to executeUse Source to performThe
The execution name of this program $n the nth parameter value of the program, n=1..9$* all parameters of the program, which can be more than 9 parameters. $# the number of parameters for this program $$ the PID of the program (the current process ID
The case name in the shell under Linux is similar to the switch in C + +, but cases in the shell are more powerful and complex.1, strong mainly reflected in: Shell in case the keyword can be a string type, and each item can contain regular
Overview
The file system (FS) shell contains various commands for interacting with HDFS, such as local FS, hftp FS, S3 FS, and other. FS shell. Run the following command:
Bin/hdfs dfs
Path URI can be used as a parameter for all Fs shells. The URI
First, I want to process many documents in a folder in batches. These documents save the data I want to process, because pig is a beginner ,, so I don't know how to load data in batches, and I haven't written it.
Your UDF can only load files one by
1. Specify the script interpreter at the beginning
#! /Bin/sh or #! /Bin/bash
2. Provide the function description, author, version, and other information at the beginning
# Description: # Author: # contact: # Last edited: # version:
Note: you
Shell operation command:
HDFS path, defined in core-site.xml
fs. Default. Name
HDFS: // master. hadoop: 9000 master. hadoop namenode Host Name
Use/to replace the current absolute path
Hadoop FS-ls/View content in the root directory of
Bash supports many operators, including Arithmetic Operators, Relational operators, boolean operators, string operators, and file test operators.
Native Bash does not support simple mathematical operations, but can be implemented using other
Summary of statements in Shell integration:
If statement:
But the if statement of the Branch:
If []; then
CMD;
Fi
If statement for dual Branch:
If []; then
Cmd1;
Else
Cmd2;
Fi
Multi-branch if statement:
If []; then
Cmd1;
Elif []; then
Cmd2;
Elif [];
[[Email protected] shell] # Cat getopts. Sh
#! /Bin/bash
# Date = 2014-09-16
# Is to practice the getopts
While getopts "A: BC" Arg (: The preceding variable must follow the parameter)
Do
Case $ ARG in
A)
Echo "A's Arg: $ optarg"
;;
B)
Echo "B"
;;
C)
Use shell commands to analyze statistics logs and shell commands to collect statistics logs
When you need to collect user log information and analyze user behavior, you can use shell to conveniently retrieve a lot of data and place it in excel for
In linux/centos shell scripts, the password is not interactively modified. In centos, the password is not modified.Today, when I wrote a shell script, I found that the user's password needs to be set and the password is set to interactive. This is
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.