在Linux用tar归档压缩文件时忽略某些文件和目录

在Linux下,常用tar对文件或目录归档压缩,有时候需要忽略某些文件或目录,怎么做呢?

原来,tar命令有个长参数 --exclude 可以用来指定排除掉的文件目录。

[root@mos178 usr]# ls motix
bin  bin.1153887679  bin.20080407zhy_something_wrong  cfg  cfg.1153887679  cfg.20070425.tar.gz  log  motix0405.tar.gz  run
[root@mos178 usr]# tar zcf motix.20130121a.tar.gz motix --exclude log --exclude "*.gz"
[root@mos178 usr]# tar ztvf motix.20130121a.tar.gz 
...
[root@mos178 usr]# 

关键是要总结出要忽略文件的模式来。

[root@sunrise root]# tar zcf work181.20130121a.tar.gz work181 --exclude log --exclude "*20*" --exclude bin                 
[root@sunrise root]# 

与tar --exclude相关的参数说明如下:

       --exclude PATTERN
              exclude files based upon PATTERN

       -X, --exclude-from FILE
              exclude files listed in FILE

       --wildcards
              use wildcards with --exclude

       --wildcards-match-slash
              wildcards match slashes (/) with --exclude

       --no-anchored
              match any subsequenceof the name’s components with --exclude

       --no-ignore-case
              use case-sensitive matching with --exclude

       --no-wildcards
              don’t use wildcards with --exclude

       --no-wildcards-match-slash
              wildcards do not match slashes (/) with --exclude


 

 

【WRF-Urban】使用 LCZ 替换 WRF 运行中的 LUCC 数据 使用 LCZ 替换 WRF 运行中的 LUCC 数据 阅读详情

相关推荐

LeGO-LOAM运行kitti数据集

文章目录1. kitti-lego-loam2. 改动3. 实验结果4. evo轨迹测评 1. kitti-lego-loam 链接:kitti-lego-loam kitti-lego-loam提供了将kitti序列转化成rosbag的代码,在kittibag中. 需要注意下数据文件的存放顺序,以00序列为例: datafolder          |____results          &

Zlp19970106的博客 8703

tar压缩文件时忽略指定文件夹、文件

.git文件太大,每次压缩上传都要耗费大量时间,所以决定忽略,tar提供忽略指定文件夹或文件的参数为 --exclude=FILE 忽略cognition中的.git文件夹–exclude=cognition/.git,注意该参数需要在被压缩文件夹之前 tar zcf cog.tar.gz --exclude=cognition/.git cognition 忽略cognition中的.txt文件,下面两种写法是一样的 tar zcf cog.tar.gz --exclude=*.txt cognitio

Debug yourself! 3976

ros2 humble中使用realsense t265与d435

前提,安装realsense SDK 2.51.1版本并且能成功启动realsense-viewer V2.51.1想要在ros2中使用realsense t265,必须配合realsense SDK v2.51.1使用realsense-ros 4.51.1版本,因为新版本realsense ros2不再对t265支持下面记录源码编译安装 realsense-ros 4.51.1版本。

m0_72797388的博客 951

tar 打包工具如何忽略一些文件或者文件夹

平时我们在使用打包工具的时候都是用这个命令进行打包。但是可能我不需要test文件夹下的test.txt文件,这时候就需要在打包的时候加上--exclude参数来忽略它。

锡城小凯的博客 2251

Windows下TensorRT+YOLOv11部署避坑指南:从CUDA配置到模型加密全流程

本文详细解析了在Windows平台部署YOLOv11与TensorRT的全流程,重点涵盖从CUDA环境配置、工程编译适配到模型加密保护的实战指南。基于wang-xinyu的tensorrtx仓库,提供了详细的版本选择、编译问题修复方案,并深入探讨了如何对TensorRT引擎进行加密,以实现高效且安全的端到端部署。

vscode5coder的博客 450

【Bug已解决】Context window exceeded / Token limit reached — Claude Code 上下文窗口超限解决方案

Claude Code 长会话中报上下文窗口/Token 超限,本质是对话历史、文件内容、工具结果累积超过 200K 上限。文中给出 /clear、/compact、分批读大文件、限制工具输出、配置 autoCompact 等完整方案。

一键难忘的博客 6727

tar命令解压时去除目录结构及解压到指定目录

一、指定去除目录结构,使用--strip-components N 如:压缩文件 file.tar 中文件信息为 three/two/one/file.txt 1、(去除第一层目录 three)运行以下命令: tar -xvf file.tar --strip-components 1 最终结果为: two/one/file.txt 2、(去除三层目录 three、two、one、)运行以下命令: tar -xvf file.tar --strip-components 3 解压结果为: file.t

x²+(y-√³x²)²=1的博客 5155

第9章:Embedding、Pooling 与检索增强基础

本文介绍了律师事务所如何利用vLLM构建法律文档RAG系统,解决传统关键词检索在语义匹配上的不足。主要内容包括: 项目背景:传统Elasticsearch检索在法律术语上的低准确率问题,及多模型维护的复杂性; 技术方案:采用vLLM统一支持生成和向量化能力,通过语义向量检索提升相关性; 关键实现: 用vLLM的Embedding端点处理文档向量化 构建包含离线索引和在线检索的完整RAG流程 采用余弦相似度进行语义匹配 实践建议:切片大小选择、向量归一化处理、不同场景下的数据库选型等。

davidwang456的专栏 59

linux忽略某些目录/文件的操作

linux命令,忽略目录/文件操作

程序猿的修炼之路 681

魔改短线利器DPO指标,频繁交易也能盈利超30倍?手机同花顺可用!

昨天我们提示了一些高位风险板块,今天来看基本上都在跌幅前列。这一波由AIGC驱动的大行情,短期来看可能已经到了尾声。中期大家可以关注30日线和60日线是否有支撑,这种现象级的生产力变革主导的行情不可能直接就凉了——哪怕相关的企业距离从中获利还很遥远。在A股,当前是否盈利并不是当前股价的主要矛盾。保守的同学不妨关注下昨天的机会列表,里边全是一些超跌的板块,短期可能会延续弱势,但是一旦站上20日线,可能就会有一波超跌反弹的行情。AIGC中的资金外流,大概率会有一些低位板块得到临幸。

量化祛魅师 老Q。 1万+

Asterisk中MixMonitor之支持接通后录音

一、概述 当我们使用开源的IPPBX(比如Elastix-2.5/4.0或者ISSABEL-4.0/FreePBX)的时候Outbound和Inbound路由(RingGroup/FollowMe)中有一个Call Recording选项,其值包括:Allow、Record immediately、Record On Answer和Nerver。当选择为Record On Answer,其实就是MixMonitor自带一个b选项。 尽管Asterisk自带的MixMoni...

宽简厚重—博约 1156

Linux 下使用 tar 命令打包指定目录下的所有文件,不包含路径方法

一,问题描述 例如:需要打包/data/android_data/VMRK02ejyijtyww20 文件夹到/data/testtar/目录下 一般我们使用命令如下命令 tar -cvf /data/testtar/VMRK02ejyijtyww20.tar -C /data/android_data/VMRK02ejyijtyww20 当我们解VMRK02ejyijtyww20.tar压缩包后发现,把路径也打包进去了, 即/data/android_data/VMRK02ejyijtyww2

以后会多把工作中总结的知识、问题处理思路和方法通过博客分享出来,欢迎大家关注和共同探讨! 1万+

大数据在电力行业的应用案例解析-【电力技术】(九)大数据在电力储能运维中的深度应用(含故障预测代码)

大数据技术为电力储能运维提供了“精准化、智能化、高效化”的解决方案,破解了传统运维的核心痛点,实现了储能系统从“被动抢修”到“主动运维”的转型,为新型电力系统建设提供了重要支撑。当前,随着储能产业的快速发展,大数据与储能运维的融合将更加深入,未来将结合人工智能、物联网、区块链等技术,实现储能运维的全流程智能化——从设备故障的提前预警,到寿命的精准预测,再到运维策略的自动优化、调度协同的实时响应,进一步提升储能系统的安全性、经济性与可靠性。

getusushu的博客 87

【linux】一文掌握 tar 指令的详细用法(tar 备忘速查)

在Linux平台上,tar命令是主要的归档实用程序。了解各种tar命令选项将帮助您掌握归档文件操作。tar代表磁带存档。

数据知道的博客 1万+

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

用tar打包时忽略文件的目录结构,不保存目录结构

       -C, --directory DIR              change to directory DIR[root@hongdi lhd]# tar -cvf c.tar -C /home/lhd a.txta.txt[root@hongdi lhd]# tar -tvf c.tar-rw-rw-r-- lhd/lhd       10240 2009-02-03 13:12

最实用的Linux博客 1万+

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Linux下的tar归档及解压缩功能详解

Linux下的tar归档及解压缩功能详解

jks212454的博客 1689

深度学习工具包 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命令大全-tar命令

tar命令是Linux系统中用于文件归档的常用工具,支持打包、压缩和解压操作。主要功能包括:创建归档文件(-c)、解压文件(-x)、查看内容(-t)等;常用压缩选项有-z(gzip)、-j(bzip2)和-J(xz);支持排除特定文件(--exclude)和指定目录(-C)。实际应用场景包括:打包时保留/删除原文件、增量备份、多文件排除等。该命令不自动压缩文件,但可与压缩工具结合使用,生成.tar.gz、.tar.bz2等压缩包。

满天点点星辰的博客 830

linux目录结构

如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。tail-f代表跟踪文件尾部内容的动态更新,便于实时监控文件内容的变化(ctrl+c停止监控)此处的“/”就是根,“/etc”中的“/”代表当前目录是以etc命名。gunzip、bunzip用法与上一个命令用法基本一致,这里不做演示。整个树形目录结构中,使用独立的一个“/”表示。解释:所有分区、目录、文件等的位置起点。grep主要是用来检索文件中的文字内容。该功能需要tree的加载,后续补充。

Rran007的博客 1769

【linux】tar命令讲解笔记

Linux tar(英文全拼:tape archive )命令用于备份文件。tar 是 Linux 和 Unix 系统中用于归档文件和目录的强大命令行工具。tar 名字来自 "tape archive"(磁带归档),最初用于将文件打包到磁带设备中,但现在广泛用于在文件系统中打包和压缩文件。tar 通常用于将多个文件和目录打包成一个归档文件,称为 "tarball"(通常带有 .tar 扩展名)。

yangchuang111213的博客 2046

Linux系统中文件的传输、归档和压缩

一、文件的传输 1.scp scp file user@ip:/dir&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;##上传 scp user@ip:/file dir&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;##下载 scp -r&amp;nbsp;&a

weixin_44209804的博客 454

Linux目录和文件管理

本章结构Linux目录结构查看及检索文件备份及恢复文件。

qq_26422089的博客 1015

tar命令

tar: 您必须从"-Acdtrux"或是"--test-label"选项中指定一个 请用“tar --help”或“tar --usage”获得更多信息。 [root@localhost nginx]# tar --help 用法: tar [选项...] [FILE]... GNU ‘tar’ 将许多文件一起保存至一个单独的磁带或磁盘归档,并能从归档中单独还原所需文件。 示例 tar ...

、moddemod 6713

tar命令(linux解压缩命令)

tar命令(linux解压缩命令)

wx1458084829 5217

Linux查看文件内容和压缩文件命令

usr/share/ 帮助文档、说明文档/var/log/ 日志/var/run/ 运行中程序/var/tmp 临时文件。

2301_76879043的博客 879

目录和文件管理

一.Linux目录结构 二.常见子目录的作用 三.查看文件内容cat命令 四.查看文件内容more命令 五.查看文件内容less命令 六.查看文件内容head、tail命令 七.统计文件内容wc命令 八.检索和过滤文件内容grep命令 九.压缩命令gzip、bzip2命令 十.归档命令tar命令 十一.文本编辑器vi命令 十二.Linux中最常用的文本编辑器

2301_76445860的博客 1283

linux目录结构和文件管理

linux目录结构及文件管理

qq_59726553的博客 960
上一篇: 在Bash脚本中怎么关闭文件描述符?
下一篇: Linux下怎样查找包含**的文件
codingstandards
博客等级 码龄16年 12粉丝 3原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值