Linux的shell编程(六)-shell的简单调试

Linux shell脚本之调试指导手册 背景 有时我们写好了一个shell脚本,但是执行时最会报一定错误,因此,运维人员可能想在脚本执行时,进行跟踪,或脚本执行前,检查脚本语法,较少脚本出错或帮助改善脚本; 操作 linux系统中,其实shell是有一个真实的调试模式的。在执行一个脚本时,可以有如下4种方式来对脚本进行调试: 1)sh -x script.sh //将执行该脚本并显示所有变量的值。-x参数,提供跟踪执行信息,将执行的每一条命令和结果依次打印出来;另-v参数可边执行脚本,边将执行过的脚本命令打印到标准错误输出。 2)sh -n 阅读详情

Linux的shell编程(六)-shell的简单调试

  • 说明: 任何语编程都有对应的调试工具??如java有Debug、mysql有调试工具、js有调试工具等。shell也不例外shell的语法检测:相当于java的编译

  • shell语法检测:

sh -n ./test.sh   (sh是/bin/sh  是系统提供的可执行脚本)
  • shell的普通调试:
sh -x ./test.sh
  • 例如调试test.sh的内容

    • 创建的test.hs
    #!/bin/bash
    echo "welcome to shell debug"
    for i in 1 2 3 4 5 6
    do
    echo $i
    done
    echo "shell debug is over"
    
    • 执行sh -x ./test.sh该语句后如下:
    	+ echo 'welcome to shell debug'
    	welcome to shell debug
    	+ for i in 1 2 3 4 5 6
    	+ echo 1
    	1
    	+ for i in 1 2 3 4 5 6
    	+ echo 2
    	2
    	+ for i in 1 2 3 4 5 6
    	+ echo 3
    	3
    	+ for i in 1 2 3 4 5 6
    	+ echo 4
    	4
    	+ for i in 1 2 3 4 5 6
    	+ echo 5
    	5
    	+ for i in 1 2 3 4 5 6
    	+ echo 6
    	6
    	+ echo 'shell debug is over'
    	shell debug is over
    	```
    * 说明进入调试模式后,Shell依次执行读入的语句,产生的输出中有的带加号,有的不带,带加号表示该条语句是Shell执行的。不带加号表示该语句是Shell产生的输出。
    
    
  • shell的中断调试:(在shell中添加一个睡眠,保证可以有时间中断调试 sleep 3 睡眠3秒执行下一个语句)

    • 创建源文件
    #!/bin/bash
    
    echo "welcome to shell debug"
    for i in 1 2 3 4 5 6
    do
    echo $i
    sleep 3 
    done
    echo "shell debug is over"
    
    • 在调试过程中可以按Ctrl + Z中断调试,观察结果,然后再按fg键继续调试即可。(先按f在按g键)
  • 使用调试工具-bashdb

    • 【功能】: 类似于GDB的调试工具,可以完成对shell脚本的断点设置,单步执行,变量观察等许多功能
    • 【场合】: 脚本比较大时,通过-x参数调试时已不方便时.
    • 【用法】:
    bashdb -c script.sh
    bashdb script.sh
    bashdb --debugger script.sh
    
    • 【说明】:该工具默认未安装,当前最新版本为:4.4-0.92,下载目录:http://bashdb.sourceforge.NET/

      • 1). 如果是ubuntu系统,直接用apt-get来安装
      apt-get install bashdb
      
      • 2). 如果是Centos等版本,使用windows下载后,编译,安装,大致步骤如下:
      下载:https://sourceforge.net/projects/bashdb/files/bashdb/
      [root@hadoop007 ~]# tar -xzvf bashdb-4.4-0.92.tar.gz -C /usr/src
      [root@hadoop007 ~]# cd /usr/src/bashdb-4.4-0.92
      [root@hadoop007 ~]# ./configure
      [root@hadoop007 ~]# make install
      
    • 【示例】

    vi /home/test1.sh
    #!/bin/bash
    echo "----------------begin-----------------"
    MAX=3
    for ((i = 0; i < MAX; i++))
    do
       nowdate=`date -d"-$i day" +%Y-%m-%d`
       echo $nowdate
    done
    echo "----------------end-----------------"
    
    • 调试命令:
    	./bashdb --debugger /home/test.sh
    	[root@hadoop007 bashdb-4.4-0.92]# ./bashdb --debugger /home/test.sh 
    	bash debugger, bashdb, release 4.4-0.92
    	
    	Copyright 2002, 2003, 2004, 2006-2012, 2014 Rocky Bernstein
    	This is free software, covered by the GNU General Public License, and you are
    	welcome to change it and/or distribute copies of it under certain conditions.
    	
    	(/home/test.sh:3):
    	3:	echo "----------------begin-----------------"  
    	bashdb<0> n #执行下一条语句
    	----------------begin-----------------
    	(/home/test.sh:4):
    	4:	MAX=3  
    	bashdb<1> l #列出当前行上下各5行,总共10行
    	  1:    #!/bin/bash 
    	  2:    
    	  3:    echo "----------------begin-----------------"  
    	  4: => MAX=3  
    	  5:    for ((i = 0; i < MAX; i++))  
    	  6:    do  
    	  7:       nowdate=`date -d"-$i day" +%Y-%m-%d`  
    	  8:       echo $nowdate  
    	  9:    done  
    	 10:    echo "----------------end-----------------"  
    	bashdb<2> b 7 #在行号为7的行设置断点
    	Breakpoint 1 set in file /home/test.sh, line 7.
    	bashdb<3> c #继续运行
    	Breakpoint 1 hit (1 times).
    	(/home/test.sh:7):
    	7:	   nowdate=`date -d"-$i day" +%Y-%m-%d`  
    	bashdb<4> print $i
    	0
    	bashdb<5> n
    	(/home/test.sh:8):
    	8:	   echo $nowdate  
    	bashdb<6> print $nowdate
    	2017-03-20
    	bashdb<7> c 10 #单步往下运行10步
    	One-time breakpoint 2 set in file /home/test.sh, line 10.
    	2017-03-20
    	Breakpoint 1 hit (2 times).
    	(/home/test.sh:7):
    	7:	   nowdate=`date -d"-$i day" +%Y-%m-%d`  
    	bashdb<8> finish  #运行到结束
    	Breakpoint 1 hit (3 times).
    	(/home/test.sh:7):
    	7:	   nowdate=`date -d"-$i day" +%Y-%m-%d`  
    	date -d"-$i day" +%Y-%m-%d
    	bashdb<(9)> finish
    	2017-03-19
    	Breakpoint 1 hit (4 times).
    	(/home/test.sh:7):
    	7:	   nowdate=`date -d"-$i day" +%Y-%m-%d`  
    	bashdb<10> finish
    	Breakpoint 1 hit (5 times).
    	(/home/test.sh:7):
    	7:	   nowdate=`date -d"-$i day" +%Y-%m-%d`  
    	date -d"-$i day" +%Y-%m-%d
    	bashdb<(11)> finish
    	2017-03-18
    	(/home/test.sh:10):
    	10:	echo "----------------end-----------------"  
    	bashdb<12> q  #退出
    	bashdb: That's all, folks...
    
    • 【常用命令】
    l             列出当前行上下各5行,总共10行
    q|quit        退出
    h             帮助
    /for/         向后搜索字符串for
    ?for?         向前搜索字符串for
    x 1+2         计算算术表达式的值
    !! ls -laRt   执行shell命令
    n             执行下一条语句
    s 4           单步执行4次,如遇到函数则进入函数里面
    b 4           在行号4处设置断点
    del 4         删除行号为4的断点
    c 10          一直执行到行号10处   
    R|run         重新执行当前调试脚本
    finish        执行到程序最后
    
Linux Shell编程 ​ Shell是一个命令行解释器程序规范,他接受应用程序/用户命令,然后调用操作系统内核完成相关的功能。它是用户使用 Linux 的桥梁。简单来说Shell 是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核的服务。也可以这样认为,linux中的shell就是linux内核的一个外层保护工具,并负责完成用户与内核之间的交互​ Shell还是一个功能相当强大的编程语言,易编写、易调试、灵活性强。 阅读详情

相关推荐

Linux下利用shell简单调试udp和tcp

链接: https://notes.z-dd.online/2024/06/16/Linux%E4%B8%8B%E5%88%A9%E7%94%A8shell%E7%AE%80%E5%8D%95%E8%B0%83%E8%AF%95udp%E5%92%8Ctcp/Linux环境下,有时候需要简单地进行下udp和tcp的测试,又不想去写C之类的代码,可以尝试下用Python或者直接用Shell来处理,简单方便,高效快捷。这里主要讲讲使用Shell的方式。客户端主要使用/dev/tcp、/dev/udp。

DD'Notes 919

Shell脚本调试技巧

脚本调试的主要工作就是发现引发脚本错误的原因以及脚本源代码中定位错误行. 方式一: 通过echo方式 【功能】: 最简单的调试方法,可以在任何怀疑出错的地方用echo打印变量 【场合】: 所有怀疑可能有问题的地方,省略了所有 【示例】: echo $VAR 方式二: 通过选项方式 -n     功能: 读取shell脚本,但不实际执行 场合: 用于测试Shell脚本中

杰瑞的专栏 7083

差分运算放大电路实战:如何用OP07搭建高精度信号采集系统(附电路图)

本文以OP07高精度运算放大器为核心,详细阐述了差分运算放大电路的设计与实现。针对微弱信号采集中的共模干扰难题,文章从电路选型、核心器件剖析、实战电路设计、PCB布局到实测验证,提供了完整的工程实践指南,并附有电路图,旨在帮助工程师构建稳定可靠的高精度信号采集前端系统。

ss78901的博客 1022

linux系统及shell常用命令

shell脚本常用代码片。查看某个作业的详细日志。shell中常用命令。

one_uueu的博客 917

别再为数据发愁了!盘点5个公开可用的医学图像数据集(含MRI/CT/PET合成任务)

本文详细介绍了5个高质量的公开医学图像数据集,涵盖MRI、CT和PET三大模态,适用于深度学习模型训练和医学图像合成任务。每个数据集均提供下载指南、预处理技巧和PyTorch加载示例,帮助研究人员快速获取和处理数据,解决医学AI开发中的数据瓶颈问题。

weixin_30689307的博客 527

【实战揭秘】高胜率集合竞价抓涨停策略:融合MACD背离与斐波那契的量化模型

本文揭秘了一种高胜率集合竞价抓涨停策略,融合MACD背离与斐波那契数列的量化模型。通过量能异动、技术形态突破和资金共识形成的交叉验证,该策略在实盘中表现出色。文章详细解析了MACD背离的量化实现细节、斐波那契数列的实战应用,以及策略的量化建模过程,帮助投资者提升交易胜率。

herb5的博客 1576

Linux中的Shell编程

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

xzy的博客 715

用Python和CasADi实现高斯伪谱法:一个轨迹优化问题的保姆级教程

本文详细介绍了如何使用Python和CasADi框架实现高斯伪谱法解决轨迹优化问题。通过保姆级教程,从环境准备、问题建模到高斯伪谱法的核心实现,包括配点与权重计算、微分矩阵构造和动力学约束实现,最终完成问题求解与结果可视化。适用于机器人轨迹规划和无人机路径优化等工程场景。

weixin_30776273的博客 294

六、Linux的Shell脚本编程

第六章:shell编程 1.1 shell的概念介绍 1.1.1 命令解释器 Shell是命令解释器(command interpreter),是Unix操作系统的用户接口,程序从用户接口得到输入信息,shell将用户程序及其输入翻译成操作系统内核(kernel)能够识别的指令,并且操作系统内核执行完将返回的输出通过shell再呈现给用户,下图所示用户、shell和操作系统的关系: 一个系统可以存在多个shell,可以通过cat /etc/shells命令查看系统中安装的shell。 .

程序猿的博客 9798

电流采样(分流器与霍尔传感器)

霍尔效应霍尔效应是磁电效应的一种,这一现象是霍尔(A.H.Hall,1855—1938)于1879年在研究金属的导电机构时发现的。霍尔效应是研究半导体材料性能的基本方法。通过霍尔效应实验测定的霍尔系数,能够判断半导体材料的导电类型、载流子浓度及载流子迁移率等重要参数。简单原理如图1所示,半导体薄片两端通以控制电流I,垂直方向施加磁感应强度为B的匀强磁场,d为半导体材料的厚度,k为霍尔常数,它与半导体材质有关,则在垂直于电流和磁场的方向上,将产生电势差为UH的霍尔电压,它们之间的关系为。霍尔元件。

weixin_48867130的博客 1万+

游戏大厂如何解析引擎技术

本文系统解析了游戏大厂如何评估和定制游戏引擎。游戏引擎作为游戏开发的核心基础,大厂会从性能、跨平台支持、渲染能力、网络模块等8个维度进行技术解析,通过文档查勘、源码阅读、Demo测试等7个步骤深度评估。解析后通常有三种决策:直接使用、深度定制或自研重构。文章以腾讯、网易、米哈游等为例,展示了不同厂商的引擎定制策略,并分析了技术解析面临的挑战和未来趋势。最终指出,体系化的引擎技术解析是打造高质量游戏的关键,需要持续的技术投入和团队协作。

本博客聚焦游戏开发技巧、创业实战心得及大学热门课程干货。这里既有技术深度,也有思维广度,无论你是开发者、创业者还是高校学子,都能在这里找到适合自己的成长之路! 536

技术干货:Linux Shell 编程基础,看这一篇就够了!

技术干货:Linux Shell 编程基础,看这一篇就够了!

cdeveloper 的专栏 4万+

软件设计师---程序设计语言

软件设计师---程序设计语言

我从不打没有准备的仗! 2万+

linux入门六:Linux Shell 编程

Shell 是 Linux 系统中用户与内核之间的桥梁,作为命令解析器,它负责将用户输入的文本命令转换为计算机可执行的机器指令。本质:Shell 是一个程序(如常见的 Bash、Zsh),而 Shell 脚本则是包含一系列命令的文本文件,通常以.sh结尾(非强制,仅为识别方便)。作用:批量执行重复命令、实现自动化任务、编写复杂逻辑程序。变量赋值空格a = 10错误,必须为a=10。中括号空格[条件]需写成[ 条件 ](如路径问题:执行脚本需用./脚本名,直接输入脚本名会提示 “命令未找到”。

嵌入式中手 1918

MATLAB 控制 E4438C 信号源的研究

通过 MATLAB,我们可以实现对 E4438C 的远程控制,从而实现更高的自动化和可编程性。总结起来,通过使用 MATLAB 和 Instrument Control Toolbox,我们可以轻松地控制 E4438C 信号源并生成各种类型的信号。需要注意的是,以上代码仅为示例,实际应用中可能需要根据具体情况进行更详细的配置和错误处理。此外,MATLAB 还提供了一系列函数和命令,可用于控制 E4438C 信号源的其他功能,如频率调谐、功率设置、调制设置等。您可以根据自己的需求进行相应的配置和控制。

RswtPerl的博客 1015

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Linux之shell编程

shell编程 shell历史        Shell的作用是解释执行用户的命令,用户输入一条命令,Shell就解释执行一条,这种方式称为交互式(Interactive),Shell还有一种执行命令的方式称为批处理(Batch),用户事先写一个Shell脚本(Script),其中有很多条命令,让Shell一次把这些命令执行完,而不必一条一条地敲命令。Shell脚本和编程语言很相似,也有变量和...

walkingLL的博客——成长之路 3万+

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

linux实验shell编程实验代写,LINUX-Shell编程实验报告.doc

《LINUX管理与应用》课程实验报告≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡实验内容和目的实验目的:理解Shell程序的设计方法;熟悉Shell程序编辑、运行、调试方法与过程。实验内容:(1)Shell 简单编程用户名回显程序;if-then、if-then-else语句使用;for语句、while语句使用(2)较复杂的考勤模拟shell程序设计实验环境微机、W...

weixin_29735807的博客 2363

深度学习工具包 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")

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Linux下串口调试及使用shell编程接收数据

串口简介 串行口是计算机一种常用的接口,具有连接线少,通讯简单,得到广泛的使用。常用的串口是 RS-232-C 接口(又称 EIA RS-232-C)它是在 1970 年由美国电子工业协会(EIA)联合贝尔系统、 调制解调器厂家及计算机终端生产厂家共同制定的用于串行通讯的标准。它的全名是”数据终端设备(DTE)和数据通讯设备(DCE)之间串行二进制数据交换接口技术标准”该标准规定采用一个 2

kaishuishushu的博客 6337

第14章 Linux的shell编程

随着各式Linux系统的图形化程度的不断提高,用户在桌面环境下,通过点击、拖拽等操作就可以完成大部分的工作。然而,许多Ubuntu Linux功能使用Shell命令来实现,要比使用图形界面交互,完成的更快、更直接。英文单词Shell可直译为“贝壳”。“贝壳”是动物作为外在保护的一种工具。可以这样认为,Linux中的Shell就是Linux内核的一个外层保护工具,并负责完成用户与内核之间的交互命令是用户向系统内核发出控制请求,与之交互的文本流。

微客猿 1883

【Linux】Shell编程【一】

Shell编程(一),关于Shell变量、运算符等

低调做人,低调编码,神码都是浮云 2311

Linux下的shell编程详解

本文摘要 本文主要从以下8 个方面介绍Linux下的shell编程: 一、Shell 编程概述 二、Shell 关键字 三、Shell 变量 四、Shell 运算 五、Shell 语句 六、Shell 函数 七、Shell 调试 八、Shell 易错点 一、Shell 编程概述 shell编程是 Linux 下的一门脚本语言——Shell 脚本。这个脚本语言可以帮助我们简化很多...

acehcl 530

Linux——Shell编程之函数与数组

所以为了避免自己编写的脚本出错,除了在编写脚本时注意书写规范,排除语法错误,更重要的是利用调试脚本工具来调试脚本。echo命令是最有用的调试脚本工具之一,一般在可能出现问题的脚本中加入echo命令,采用的是分段排查的方式。在Linux上编写Shell脚本的时候,经常需要递归遍历系统的目录,列出目录下的文件和目录,逐层递归列出,并对这些层级关系进行展示。该函数会定期监控系统的CPU和内存使用率,当使用率超过设定的阈值时,就会发送报警信息提醒,这里将简单模拟实验环境,实际的应用中还会扩展为发送邮件、短信等。

Lemon__ing的博客 1685

Linux Shell脚本调试的四种办法

Linux脚本调试前言bash自身特性-v-n-x-x的增强$LINENO$FUNCNAME$[PS4](https://blog.51cto.com/kusorz/1968827)功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入

jaykk的博客 1万+

linux shell程序设计实验报告,linux-shell编程实验报告

《linux-shell编程实验报告》由会员分享,可在线阅读,更多相关《linux-shell编程实验报告(8页珍藏版)》请在金锄头文库上搜索。1、LINUX管理与应用课程实验报告实验内容和目的实验目的:理解Shell程序的设计方法;熟悉Shell程序编辑、运行、调试方法与过程。实验内容:(1)Shell 简单编程用户名回显程序;if-then、if-then-else语句使用;for语句、whi...

weixin_29332029的博客 3201
上一篇: Linux的shell编程(五)-方法(函数function)
下一篇: Flume案例-Avro&Exec&Exec&Syslogtcp&JSONHandler&HDFS sink&File Roll Sink&channels
lds_include
博客等级 码龄11年 40粉丝 97原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值