#!/usr/bin/perl
#######################################################################
# file name: lessfind #
# use less to open specific files by pattern in current folder #
#######################################################################
my $me = `basename $0`;
chomp($me);
sub showHelp{
print "Usage $me [-dnumber] file-pattern1 [file-pattern2] [...]/n";
print "-d: search depth/n";
print "the file pattern is case insensitive/n";
}
my $maxdepth = undef;
if(@ARGV == 0){
showHelp();
exit 0;
}elsif(@ARGV == 1){
my $arg1 = $ARGV[0];
if($arg1 =~ m//-d/d*/){
showHelp();
exit 1;
}
}else{
my $arg1 = $ARGV[0];
if($arg1 =~ m/^(/-d)(/d+)$/){
$maxdepth = $2;
}else{
showHelp();
exit 1;
}
}
my %files = ();
my $index = 1;
my $startIndex = defined $maxdepth ? 1 : 0;
# execute find
for($i = $startIndex; $i < @ARGV; $i++){
my $pattern = $ARGV[$i];
my $maxdepthArg = $maxdepth > 0 ? " -maxdepth $maxdepth " : "";
my $findcmd = "find . $maxdepthArg -xtype f -iname /"*$pattern*/" 2>/dev/null";
# print "$findcmd/n";
my $filelist = `$findcmd`;
chomp($filelist);
my @items = split("/n", $filelist);
# add find results
foreach $item (@items){
if($files{$item} eq ""){
$files{$item} = $index++;
}
}
}
if($index == 1){
print "No matched files are found!/n";
exit 0;
}
my @menu = ("exit");
foreach $file (keys(%files)){
my $key = $file;
my $no = $files{$key};
$menu[$no] = $key;
}
# if only one hit, open it by default
my $cmd;
if($#menu == 1){
$cmd = "cat -n $menu[1] | less";
}else{
# display menu
for($i = 1; $i < @menu; $i++){
print "$i. $menu[$i]/n";
}
print "0. $menu[0]/n";
print "input file no:";
# waiting user input
my $line = <STDIN>;
chomp($line);
# open file
if($line =~ m/[0-9]/ && $line > 0 && $line < @menu){
$cmd = "cat -n $menu[$line] | less";
}
}
print "$cmd/n";
system("$cmd");
exit 0
相关推荐
STM32解析航模遥控器的PPM信号
使用STM32对航模遥控器的PPM信号进行解析
less find grep命令
less find grep命令
OpenCV 常用的API总结(迅速查询)
OpenCV基本操作 openCV安装 读取图片(IO操作) 绘制集合图形 图像加法以及混合操作 OpenCV图像处理 图像几何变换 形态学操作 图像平滑 直方图 边缘检测 模板匹配 傅里叶变换 轮廓检测 图像分割 图像特征提取 SIFT检测关键点 视频读写............
linux less查找特定字符串,Linux文件查找命令find,xargs详述
1.find由于f i n d具有强大的功能,所以它的选项也很多,其中大部分选项都值得我们花时间来了解一下。即使系统中含有网络文件系统( N F S ),f i n d命令在该文件系统中同样有效,只你具有相应的权限。在运行一个非常消耗资源的f i n d命令时,很多人都倾向于把它放在后台执行,因为遍历一个大的文件系统可能会花费很长的时间(这里是指3 0 G字节以上的文件系统)。F i n d命令的...
Synares病毒实战:如何手动清除C盘隐藏的Synaptics.exe(附资源修复脚本)
本文详细介绍了Synares感染型病毒的手动清除方法,该病毒伪装成Synaptics触摸板驱动,感染EXE和XLSX文件。文章提供了从病毒行为分析、母体清除到被感染文件修复的全流程指南,并附有实用的资源修复脚本和防御加固方案,帮助用户彻底清除这一顽固病毒。
Axure RP 10表单数据提交制作
本文介绍了如何使用Axure RP 10实现表单数据提交。
Linux系统的常见命令二(more命令、less命令、grep命令和find命令)
本文主要介绍Linux系统的more命令、less命令、grep命令和find命令
从零到一:手把手教你用STM32F103C8T6打造个人专属开发板(附立创EDA工程与源码)
本文详细介绍了如何使用STM32F103C8T6微控制器从零开始设计和制作个人专属开发板。内容涵盖硬件选型、原理图设计、PCB布局、功能验证等全流程,并提供了立创EDA工程文件和源码,帮助开发者深入理解STM32开发板的硬件架构与设计要点。
Linux——几个重要的指令man、cp、mv、 cat、more、 less、find
-f 或 --force 强行复制文件或目录, 不论目的文件或目录是否已经存在less 工具也是对文件或其它输出进行分页显示的工具,功能极其强大。 less 的用法比起 more 更加的有弹性。在 more 的时候,我们并没有办法向前面翻, 只能往后面看 -i 或 --interactive 覆盖文件之前先询问用户 -r递归处理,将指定目录下的文件与子目录一并处理。若源文件或目录的形态,不属于目录或符号链接,则一律视为普通文件处理 -R 或 --recursive递归处理,将指定目录下的文件及子目录一并处理
华为Ascend_toolkit在x86ubuntu安装失败报错。[WARNING] driver package is not installed. If you install in docker
这个报错发生在交叉编译配置Ascend_toolkit环境时,安装Ascend_toolkit安装包的时候发生。[Y/N]Y。
HDR 人像肤色稳定实战:AE/AWB/ToneMap 冲突解耦与优先级裁决
人像 HDR 最容易“翻车”的就是**肤色飘**:AE 抢亮度、AWB 拉白点、TM 又在肩部压高光,三方各自“对”却合起来“错”。本文给出一套**工程可落地**的裁决策略:以**肤色 ROI 锚点**为最高约束,AE 先对脸部入射照度收敛,AWB 在**肤色先验 + 光源模型**下缓变,TM 采用**色相保持 + 中灰/肤色双锚**且时域一致化。配套**阈值与回归**(ΔE00、亮度漂移 RMS、频闪注入),把“主观对”的口径落到**可度量**,并给出逆光、多脸、霓虹等极端场景的**例外分流**。
LINUX find命名,以及cat、more、less、tail、head命令的区别
1、find说明: Linux中find常见用法示例· find path -option [-print ] [ -exec -ok command ] {} \;# -print 将查找到的文件输出到标准输出 # -exec command {} \; -----将查到的文件执行command操作,{} 和 \;之间有空格 # -ok 和-exec...
【深度学习新浪潮】气候预测模型的研发进展一览(2025年版)
模型类型核心优势适用场景不足ARIMA(统计模型)简单高效、可解释性强短期单变量预测非线性、长时依赖建模差随机森林(机器学习)多特征融合、抗噪声中短期多因素预测空间相关性、时序趋势捕捉弱LSTM(深度学习)长时依赖建模、端到端中长期时序预测物理一致性差、数据需求量大物理知情AI物理规律约束、高可靠性极端天气、长期气候变化模型复杂、计算成本高。
Linux-1.4文件操作命令(grep,cat,tail,head,less,find,chmod,tail,less)
Linux基础命令(grep,cat,tail,head,less,find,chmod,tail,less) grep(常用) grep 指定“文件”搜索文件内容 grep hello 1.txt 在文件中查找字串 grep -n hello 1.txt 显示字串的行数 grep -i hello 1.txt 不区分大小写 grep -in hello 1.txt显示字串...
ET2012新版免狗免安装绿色软件
ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,
深度学习工具包 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');```[](https://bitdeli.com/free "Bitdeli Badge")
linux less命令查找文件包含字符串
介绍下less命令用来查找日志 1.less 日志文件名.后缀 2.G 定位到日志文件的最后一行 3.?order 从最后一行向上查找包含order的地方 4.敲回车 触发查找 5.n 从下向上翻找下一个包含order的地方 6.N 从上向下翻找下一个包含order的地方 ...
NTscan扫描工具
ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。
Less Sass
less 变量 可运算 对常用的值进行定义,然后应用到样式中,这样只要改变你定义的变量参数值就可以达到改变全局的效果 .border{ border:1px solid red; } @color :blue; //定义变量 @blue : 'color' ; @height:10px; @width:100px; #header { .border //混入class height: @height; width: @width; color: @@blue;
蓝牙模块HM-10手册
蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。
less 查看日志,并且搜索
一、关键字搜索日志【非常实用】 1:less catalina.out 2:大写字母:F【find的意思,并且其实他正在计算行数】直接到达日志最底部,也就是最新日志 3:ctrl+c【把上面的计算行数运算停止】 4:?要搜索的字符【用通配符?开始查找】 5:键盘上下键来查看 【 上下键, 空格下一页, 字母B上一页 , 字母Q退出, n(小写字母n)上一个关键字位置 ...
使用perl计算日期
#!/usr/bin/perlsub addDate{ ($delt) = @_; my $date = time() + 60 * 60 * 24 * $delt; (undef, undef, undef, $day, $month, $year) = localtime $date; $year += 1900; $month++;
findline
#!/bin/bash ###################################################### # file name: findline # # find lines
ax
#!/bin/bash ########################################### # file name: ax # # set file to be executable for all users # ########################################### ME=`basename $0` showHelp() { echo "usage $ME file_name1 [
killprocess
#!/usr/bin/perl######################################################################## file name: killprocess ## kill process by pid
catfind
#!/usr/bin/perl######################################################################## file name: catfind ## use cat to open specific files by
vifind
#!/usr/bin/perl ################################################## # file name: vifind.pl # # vi specific files by pattern in current folder # ################################################## my $me = `basename $0`; chomp
lesslast
#!/bin/bash######################################################################## file name: lesslast ## use less to open last file by ls -lt
vilast
#!/usr/bin/ksh ###################################### # vi last file by 'ls -ltrF' command # ###################################### vi `ls -ltrF | sed -n '$p' | awk {'print$NF'}`
catlast
#!/bin/bash ################################################################## # file name: cat last # # display last file by 'ls -ltrF' command # #######################################
9734



被折叠的 条评论
为什么被折叠?



