Shell Exercises 1

Exercise one: Write a script 1. Set the value of the variable file to/etc/passwd 2. Say hello to each user in/etc/passwd, and say what the ID is like: (Hint: line= ' wc-l/etc/passwd |       Cut-d ""-f1 ') Hello,root,your UID is 0. 3. Count the

Linux shell command

(1) Manipulating a file and slicing the file query rows  grep ' XXX ' Cut 2 (or 1-2)(2) The operation of the file to remove the weight and show the number of repetitionsgrep ' xxx ' Cut 2 Sort Uniq -C(3) View total number of totals rowsgrep ' XXX '

Shell script Programming (i)

One, bash variables:Variable naming laws:1. The reserved words in the program cannot be made: for example if, for;2, only use numbers, letters and underscores, and cannot start with a number3. See the meaning of the name4, the Uniform naming rule:

Variable explanation of shell programming

Types of variables in bash1. Local variable: The active scope is the current shell process and is not valid for Shell processes other than the current shell, including the current Shell's child shell processVariable assignment: name= ' value 'Use

Shell script Programming--if statements

How to handle the programming logic:1, sequential execution2, select Execute3, loop executionConditional Select if statementSelect Execute:Note: If statements can be nestedSingle Branchif judgment condition; thenBranch code with true

Regular expression of the Linux--shell script

First, the concept and characteristics of regular expressions:A regular expression is a logical formula for a string operation, which is to make a "rule string" with a predefined set of characters and a combination of those specific characters.This "

Progress bar---shell script implementation

1. Procedure650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/85/99/wKiom1epjIzSGVmbAABUg44vkDo770.png-wh_500x0-wm_3 -wmp_4-s_3200651285.png "style=" Float:none; "title=" Captures 1. PNG "alt=" Wkiom1epjizsgvmbaabug44vkdo770.png-wh_50 "/>2.

Shell loops, simple little exercises

1. The array is full of positive integers greater than 0, using the shell to find the maximum, minimum, and average values (2 decimal places reserved)650) this.width=650; "src="

Shell's log processing

#!/bin/bash#by lc at 20160428 for hadoop (grep_recharge) DATE= ' Date +%F_%H\:%M\:%S ' ytdate= ' date -d  " -1 day"  +%y%m%d ' restdir=/home/hadoop/prodata/restdatedir=/home/hadoop/ prodata/rest/$YTDATERESTFILE =${datedir}/recharge-$YTDATE.

Shell String Common operations

Reference article: http://blog.csdn.net/chen_jp/article/details/8922582One-character substitutionOrigin= the original string str= the replaced stringReplace command:str=${origin//the target character / replaced character }For example:str=${origin//:/

Bash Shell Basics

Bash a few common code######## #最简单的bash#! /bin/bash #解析器路径 env #查看环境######### #看运行时间#!/bin/time. SH start=$ (date +%s) #commands; #statements; Sleep Ten ; #command End=$ (date +%s) Difference=$ ((End-

Shell of Leetcode

1.Tenth LineHow would you print just the 10th line of a file?For example, assume this file.txt has the following content:Line 1Line 2Line 3Line 4Line 5Line 6Line 7Line 8Line 9Line 10Your script should output the tenth line, which is:Line 10----------

Fundamentals of shell programming for Linux learning articles

Set Environment variables:①export variable name = variable Value #设置环境变量② variable name = variable Value #设置环境变量Export variable NameSet #显示当前shell所有变量Env #查看环境变量unset variable name #删除变量Common environment variables:Path variable: Paths to System

Run scripts in different ways in the shell

In the shell, you can run the script in 3 ways:1. ./script_name or source./script_name2 Direct./script_name3./script_name &Join script Script_name There are two command command1,command2, then, when run in the first way, Command1 and Command2 both

Shell script Batch processing string

Last Friday operations there was a excle for a mobile phone number, asking for information about all users that correspond to user numbers. This time encountered a problem is that you need to query the number of users, not one to check, and excle in

Shell One-click View Linux hardware configuration

I took over two projects, suddenly the eldest brother asked me what configuration of the server, then I was ignorant, has not been too concerned about this thing, just to ensure that the server normal operation, the site can access normal, the other

Shell Case-Top Ten commands you like to hit ^ v ^

This is the age of big data!But have you ever thought of yourself as a bowl of big data? Chinese medicine said, talent is the most complex and the most magical natural products, first from the beginning to understand their own ...What do you think

Double-brace expressions in the shell

Syntax format((expression))Expression can be any mathematical expression that can contain the following operators:+ Plus-Minus* Multiply (no escaping)/except% take-up* * Index= = equals! = Range> Greater than>= greater than or equal to&& Logic and||

Shell file Self-write

time=$ (date +%y%m%d)             mkdir $ time               cd  $time      touch 0.txt touch 0.ctouch 0.cctouch 0.cpptouch 0. htouch makefiletouch 0.sh   echo  "#include "  >> 0. cecho  "#include "  >>0.cecho  "Void fun ()"  >> 0.cecho   "{"

Add the jar that the user needs when starting with cluster mode in Spark-shell

Want to test the Elasticsearch operation of cluster mode in Spark-shell,# 1 Download the relevant jar first# 2 Use--jars when starting Spark-shell./bin/spark-shell–master Spark://master:7077–jars/usr/local/spark-1.6.2/lib/elasticsearch-spark_2.10-2.2

Total Pages: 541 1 .... 465 466 467 468 469 .... 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.