Linux Shell编程快速入门

Linux快速入门教程:命令行与Shell编程 Linux 系统的目录结构有一个统一的标准,称为 Filesystem Hierarchy Standard(FHS),它定义了目录和文件的基本位置和目录内容。掌握网络配置的第一步是要了解一些基础的网络概念。Linux系统支持多种网络协议,最常用的包括IPv4和IPv6。理解IP地址、子网掩码、网关以及DNS的作用是进行网络配置的前提。 阅读详情

目录

  • 章节1:变量
  • 章节2:逻辑和算术运算
  • 章节3:流程控制
  • 章节4:函数
  • 章节5:其他

附:题目实例讲解


1. 变量

#!/bin/bash

# 初始赋值和变量使用
a=12
echo $a # echo ${a}

# 只读变量
a="hello"
readonly a

# 删除变量
unset a

# 字符串拼接
a="hello"
b="world"
echo "jt,"$a$b

# 获取字符串长度,获取数组长度
a="hello"
echo ${#a}
a=(12 34 89 90)
echo ${#a[@]}

# 提取字符串
a="i love you"
echo ${a:2:4}

# 数组赋值和修改
a=(12 90 90 89)
echo ${a[0]}
a[0]=34
echo ${a[0]}
b=${a[2]}

# 数组遍历
a=("H" 10 90 89)
for((i=0;i<${#a[@};i++));do
	echo ${a[$i]}
done

# 某个变量统一大小写(-u,-l)
typeset -u opt
opt="hello"
echo $opt

# 变量内嵌等价(下面两种方式一样的)
opt="hello"
echo "$opt world"
opt="hello"
echo $opt" world"

# 显示执行结果
echo `date +"%Y-%m-%d %H:%M:%S"`

# printf的格式化输出
printf "%-10s %-8s %-4.2f %d\n" 郭靖 男 66.1234 20
>>#输出:郭靖 男 66.12 20


# 判断字符串是否为空
if [ $a ]
then
	..
	

# 判断字符串长度是否为0
if [ -z $a ]
then
	..



2. 逻辑和算术运算

#!/bin/bash

# 算术运算方式1 expr
val=`expr 2 + 2`
echo $val
val=`expr $a + $b`
echo $val

# 算术运算方式2
a=123
b=23
c=$[a+b]
echo $c
d=$[40 + 30]
echo $d

# 算术运算方式3 let(最直观)
a=12
b=20
let c=a+b
echo $c


# 文件是否存在
if test -e ./files/1.txt
then
	echo "Y"
else
	echo "N"
fi

# 与或非(-a与,-o或,!非)
if test -e ./notFile -o -e ./bash
then
    echo "至少有一个文件存在!"
else
    echo "两个文件都不存在"
fi

# 与或(&&与,||或)
if [[ $num1 -gt $num2 && $num3 == $num4 ]]
then
	...

# 等于,不等于(方式1)
num1=100
num2=200
if test $[num1] -eq $[num2]
then 
	echo "Equal"
else
	echo "Not Equal"
fi

# 等于,不等于,大于小于(方式2)
num1=100
num2=200
if [ $num1 == $num2 ] 
then 
	echo "Equal"
else
	echo "Not Equal"
fi





3. 流程控制

#!/bin/bash

# 条件语句
a=10
b=20
if [ $a -lt $b ]
then
	echo "Y1"
elif [ $a -gt $b ]
then
	echo "Y2"
else
	echo "Eq"
fi

# case判断
read opt
case $opt in
	1)
		echo "you input 1"
	;;
	"q")
		echo "you input q"
	;;
	*)
		echo "others"
	;;
esac

# 循环语句(直接遍历)
for v in 12 43 43
do
	echo $v
done

# 示例:遍历目录
for f in `ls /usr`
do
	echo $f
done

# 循环语句(C风格)
a=(12 43 434)
for((i=0;i<${#a[@]};i++));
do
	echo ${a[$i]}
done

# 循环语句(while 条件)
idx=0
while((idx<5))
do
	echo $idx
	let idx++
done

# 循环读入
typeset -l num
while read num
do
	echo $num
done

# break和continue
while read opt
do
	if [ $opt == "q" ]
	then
		echo "out"
		break
	fi
done

4. 函数

#!/bin/bash

# 函数书写与传参和返回
add(){
    echo $1
    b=`expr $1 + $2`
    return $b
}

add 12 90
c=$?
echo $c

# bool判断(0代表true,其他数值代表false,一般用-1更好区分)
func(){
    if [ $1 == $2 ]
    then
        return 0
    else
        return -1
    fi
}

if func 12 90
then
    echo "true"
else
    echo "false"
fi


5. 其他补充

# 用于查看安装的shells
cat /etc/shells

# 给脚本增加执行权限
chmod +x run.sh

# 大于小于,大于等于, 小于等于(数字)
-gt -lt -ge -le

# 判断字符串是否相等,只有一个等号
=

# 跟踪模式执行某个脚本
/bin/bash -x run.sh


附:示例编写

例子1:
在这里插入图片描述

#!/bin/bash
options_show(){
    echo "Use one of the following options:"
    echo "P:To display current directory"
    echo "S:To display the name of running file"
    echo "D:To display today's date and present time(如:2017-04-26 05:45:12) "
    echo "L:To see the list of files in your present working directory"
    echo "W:To see who is logged in"
    echo "I:To see the ip address of this local machine"
    echo "echo \"Q:To quit this program"
    echo "Enter your option and hit:"
}

typeset -l opt
options_show
while read opt
do
    case $opt in
    "p")
        echo `pwd`
    ;;
    "s")
        echo $0
    ;;
    "d")
        echo `date +"%Y-%m-%d %H:%M:%S"`
    ;;
    "l")
        echo `ls .`
    ;;
    "w")
        echo `whoami`
    ;;
    "i")
        echo `ifconfig`
    ;;
    "q")
        break
    ;;
    esac
    options_show
done

例子2
在这里插入图片描述

#!/bin/bash
show(){
    echo "Please input your score:"
}

show
while read score
do
    if [ $score -lt 0 ]
    then
        break
    elif [ $score -lt 60 ]
    then
        echo "Failed"
    elif [ $score -ge 60 -a $score -le 69 ]
    then
        echo "Passed"
    elif [ $score -ge 70 -a $score -le 79 ]
    then
        echo "Medium"
    elif [ $score -ge 80 -a $score -le 89 ]
    then
        echo "Good"
    elif [ $score -ge 90 -a $score -le 100 ]
    then
        echo "Excellent"
    fi
    show
done

例子3
在这里插入图片描述

#!/bin/bash
show(){
    echo "Please input your dir-path:"
}

while read dir
do
    if [ $dir = "q" ]
    then
        break
    fi
    if [ -e $dir ]
    then
        idx=0
        fns=(`ls $dir`) # 这个括号非常重要,可以转成数组
        ls -l $dir | while read x
        do
            if [ $idx == 0 ]
            then
                let idx++
                continue
            else
                echo "/"${fns[$idx-1]}"_"${x:0:1}
                let idx++
            fi
        done
    else
        echo "This path is not exists!"
    fi
    show
done

这里,如果是带有空格的行就需要用read的方式来分割,如果是空格的分割,只需要用数组转换法即可

例子4
在这里插入图片描述

#!/bin/bash
while read opt
do
    for((i=$opt;i>=1;i--));do
        for((j=$i;j>=1;j--));do
            echo -n "$j " #不换行
        done
        echo
    done
done

例子5

在这里插入图片描述
需求1:启动和关闭ftp服务:

#!/bin/bash
systemctl start vsftpd
if [ $?!=0 ];then
	echo "start ftp error" | mail -s "start ftp error" root
else
	pinfo=`ps -ef | grep vsftpd | head -n 1`
	date=`date +"%Y-%m-%d"`
	echo $pinfo>>/var/ftp/${date}.log
fi
#!/bin/bash
systemctl stop vsftpd
if [ $?!=0 ];then
	echo "Stop ftp error" | mail -s "Stop ftp error" root
fi

需求2:ping Baidu:

#!/bin/bash
date=`date +"%Y-%m-%d"`
ping -c 4 >>/var/ftp/${date}.log

需求3:打包日志:

#!/bin/bash
date=`date +"%Y-%m-%d"`
tar -czvf "/root/${date}.tar.gz" /var/ftp
chmod 400 "/root/${date}.tar.gz"
rm -rf /var/ftp/*
fdtd(时域有限差分)仿真 基础入门阶段采用 Step by step 的教学方式带着做具体的案例,在案例中学习 FDTD 应用的。的痛难点,将 FDTD 仿真引入实验当中,通过软件可视化处理有效直观的展示仿真的流程,与实验数。图像传感器,OLED 和液晶,表面计量,表面等离子体,石墨烯,太阳能电池,集成光子组件,超材。料,衍射光学和光子晶体。波,场极化,磁场,周期性结构,半球功率积分等设计解决方案,提供时域有限差分分析函数,时域。子光学传感器、热电子光探测器的光学特性研究、光学微腔宽带吸收器等多个方向的研究方法。 阅读详情

相关推荐

find命令

命令是 Linux/Unix 系统中用于搜索文件和目录的强大工具,支持多种搜索条件组合,并能对搜索结果执行各种操作。以下是其详细说明、常用参数及示例: 搜索路径:指定起始目录(如 、 或 表示当前目录)。 查找条件:基于文件名、类型、大小、时间等属性过滤。 处理动作:对匹配结果执行操作(如打印、删除、执行命令等)。 常用参数及示例 1. 按名称查找 :区分大小写匹配文件名。 :不区分大小写匹配文件名。 2. 按文件类型查找 :指定文件类型。 文件类型: :普通文件 :目录 :符号链接

qiao2458的博客 1135

【Linux】快速入门shell编程

每天都得进步,哪怕是一点! 文章目录一.shell基本介绍1.基本介绍2.shell脚本的执行要求3.脚本的常用执行方式二.shell变量1.基本介绍2.shell变量的定义和撤销3.定义变量的规则4.将命令的结果赋值给变量5.设置环境变量7.位置参数变量8.预定义变量9.shell中的运算符三.流程控制-条件控制1.条件判断基本语法2.常用的条件判断 `重点`2.1.字符串比较2.2.两个整数的比较2.3.按照文件权限进行判断2.4.按照文件类型进行判断2.5.基本案例3.if判断语句3.1.基本语法3.

xiexianyou666的博客 2298

HCLR-Net: 混合对比学习正则化与局部随机扰动用于水下图像增强

独特贡献在于开发了一种处理负样本的新策略,既保留了负样本的统计特性,又防止网络过度剖析这些样本中的特征信息。通过根据每个通道特征的重要性对模型进行加权,我们可以增强富含上下文信息的通道,从而获得更准确、更详细的特征表示。AHA 模块利用垂直方向上的 Avgpool 和水平方向上的 Maxpool 来捕捉远程依赖关系和准确的位置信息,从而有效确定不同方向上的特征退化。对比学习策略通常旨在最小化正样本之间的欧氏距离,使预测图像更接近理想图像,同时最大化负样本与预测图像之间的距离,使它们进一步远离非理想表征。

G-Howe的博客 1457

Linux 当中 Shell 编程(超级详细快速入门上手到熟悉)

Shell被翻译为“壳”。在Linux内核外面包了一个壳。Shell是一种用于与操作系统进行交互的命令行解释器。它是一种脚本语言,可以通过编写一系列的命令和脚本来执行操作系统的功能和任务。我们在终端中编写的命令都是Shell命令。例如:ls、grep…等。Shell 是一个命令行解释器,它为用户提供了一个向 Linux 内核发送请求以便运行程序的界面系统级程序,用户可以用 Shell 来启动、挂起、停止甚至是编写一些程序。看一个示意图。

weixin_61635597的博客 2759

OpenStack [ compute_id ] 设计上的小缺陷

而 nova 代码中硬编码(或默认配置)将 compute_id 放在 site-packages 目录,属于 设计上的小缺陷—— 把 “库安装目录” 和 “运行时数据目录” 混在一起了,才导致需要临时调整这个目录的权限。# 配置项说明:node_identity_file 是 nova 用于指定节点标识文件路径的官方配置项,优先级高于代码中的默认路径。自定义 compute_id 路径,指向 /var/lib/nova/ 目录下的 compute_id 文件;

求知若渴,虚心若愚。 491

1. 在 SAP ABAP 事物码 SEGW 里创建 SAP OData 项目

本文介绍如何在 SAP ABAP 事物码 SEGW 里创建 SEGW 项目,使用工具生成 Runtime 运行时需要的资源。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 5442

Linux Shell编程快速入门以及案例(Linux一键批量启动、停止、重启Jar包Shell脚本)

本文针对Linux初学者,详细介绍了Shell编程的十个核心概念,并通过具体示例帮助读者理解和掌握这些概念。希望本文能为Linux初学者在学习Shell编程的道路上提供有益的指导。重定向用于改变命令的输入输出方向,常见的重定向有标准输入(stdin)、标准输出(stdout)和标准错误输出(stderr)。单引号和双引号有不同的作用,单引号会忽略特殊字符,而双引号会保留特殊字符的原本含义。通配符用于匹配文件名,常见的通配符有*(匹配任意字符)、?管道用于将一个命令的输出作为另一个命令的输入。

tigerhhzz的博客 1484

MaxScript批量修改材质、贴图名称

MaxScript批量修改材质、贴图名称1 实现效果1.1 修改前材质、贴图名称1.2 修改后2 代码 1 实现效果 1.1 修改前材质、贴图名称 1.2 修改后 2 代码 prefixName = "prefiname" maxFile = "maxfilepath" makeDir "newBitmappath" mapsPath = newbitmappath + "\\" fn formatStr index = ( str = index as string newS

郑德帅 3241

Linux之shell编程快速入门【紧扣课本教程】

扩展 Linux就该这么学:https://www.linuxprobe.com/ 一:输入输出重定向 输出:>> 输入:< 1.输入重定向 < 用cat < 现实输入指定的文本文件类容 2.输出重定向 >> 现实当前文件下的项目,创建一个文本txt,然后输出到txt中并显示出来 二:数字变量赋值 创建一个shell文件,实现数字变量的加法运算 三:for循环(in) 利用for循环实现简单...

刘鑫磊 3186

破解现代反爬虫:JS加密、OB混淆与CSS反爬的实战攻防分析

摘要: 随着反爬技术的升级,JS加密、OB混淆和CSS反爬成为主流防护手段,阻碍传统爬虫获取数据。本文解析了这些技术的工作原理,并提出破解策略:通过模拟浏览器(如Selenium、Puppeteer)执行动态JS,逆向混淆代码,以及利用开发者工具突破CSS隐藏。针对复杂防护,开发者需结合技术分析与工具应用,如API接口抓取、动态渲染破解等,以应对不断演进的反爬机制。未来,爬虫攻防将持续升级,需保持技术敏锐性。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1646

【Settings随记:二】一级菜单,二级菜单的添加与隐藏,添加辅助功能

首先会去调用父类的onCreatePreferences(Bundle savedInstanceState, String rootKey)方法,然后调用addPreferencesFromResource(R.xml.assistant_function)方法(这个方法是父类的)加载二级菜单的xml配置文件,实现创建二级菜单,这个配置文件路径在res/xml/assistant_function.xml。controller:该item的控制器,控制它的内容展示,是否可用,也可以控制它的点击事件等。

镇元子的博客 1595

Linux_shell编程快速入门

shell是一个命令行解释器,它为用户提供了一个向Linux内核发送请求以便运行程序的界面系统级程序。用户可以用Shell来启动、挂起、停止甚至是编写一些程序。说明:不用赋予脚本+x权限,直接执行即可。脚本的+x权限,再执行脚本。

qq_63388834的博客 379

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

for linux shell 菜鸟_Shell 编程快速入门

什么是Shell脚本?Shell脚本(英语:Shell script)是一种电脑程序与文本文件,内容由一连串的shell命令组成,经由Unix Shell直译其内容后运作。被当成是一种脚本语言来设计,其运作方式与直译语言相当,由Unix shell扮演命令行解释器的角色,在读取shell script之后,依序运行其中的shell命令,之后输出结果。利用Shell script可以进行系统管理,文...

weixin_31518415的博客 131

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Linux学习笔记09 -- 超详细shell脚本编程快速入门

文章目录1.shell简介1)什么是shell2)shell脚本3)运行shell脚本4)shell注释5)shell编写的基本步骤2.shell变量1)命名变量2)使用变量3)变量类型3)变量操作3.shell字符串1)字符串类型2)字符串操作4.shell数组1)定义数组2)数组操作5.shell传递参数6.shell运算符1)shell运算符种类2)算数运算符3)关系运算符4)布尔运算符5)...

Freedom_Blue的博客 7万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

linux-Shell编程入门到快速实战

1.5 运算符-$[算法表达]/expr算法表达... 7 1.6 条件判断-[ condition ] 10 1.7 流程控制... 11 1.7.1 if 判断... 11 1.7.2 case 语句... 12 1.7.3 for 循环... 13 1.7.4 while 循环... 17 1.8 read读取控制台输入... 18 1.9 函数... 18 1.9.1 系统函数... 18 1.9.2 自定义函数... 19 1.10 Shell工具(重点)... 20 1.

互联网知识分享 351

Linux之shell编程(一)--- shell编程快速入门

1. 为什么要学习Shell编程 Linux运维工程师在进行服务器集群管理时,需要编写Shell程序来进行服务器管理。 对于JavaEE和Python程序员来说,工作的需要,你的老大会要求你编写一些Shell脚本进行程序或者是服务器的维护,比如编写一个定时备份数据库的脚本。 对于大数据程序员来说,需要编写Shell程序来管理集群。 2. Shell是什么 Shell是一个命令行解释器,它为用户提供了一个向Linux内核发送请求以便运行程序的界面系统级程序,用户可以用Shell来启动、挂起、停止甚至是编写

等风来的博客 616

Linux Bash Shell编程快速入门

http://www.sphinxsearch.org/archives/414 ----- BASH 的基本语法 最简单的例子 —— Hello World! 关于输入、输出和错误输出 BASH 中对变量的规定(与 C 语言的异同) BASH 中的基本流程控制语法 函数的使用 2.1     最简单的例子 —— Hello World!

faral的专栏 535

Linux Shell 编程快速入门(2026版)

Linux Shell 编程快速入门

普普通通记录学习日常 508

Linux快速入门(3)——20分钟掌握Shell编程

本文针对Linux的新手小白,对Shell编程进行入门级的讲解,从运行第一个Shell程序Hello World,到设计编写复杂的综合脚本程序,本文给出了手把手的教学和相应代码,为想要入门Bash编程的小伙伴提供了学习指南和入门教程。

猪猪和超超的博客 603

Linux快速入门-一道简单shell编程题目

一道shell脚本简单题目

qq_40498068的博客 491

系统shell编程学习

Linux Shell脚本教程:30分钟玩转Shell脚本编程 http://c.biancheng.net/cpp/shell/ Linux入门教程(更新完毕) http://c.biancheng.net/cpp/linux/ 刷掉此页 2015.7.29始 转载于:https://www.cnblogs.com/daijkstra/p/4687570.html...

weixin_30657541的博客 82
上一篇: Hadoop 实验MR编程速记
下一篇: 华南农业大学 Linux 实验大全
JintuZheng
博客等级 码龄11年 1483粉丝 109原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值