tar

「杂录」CSP-S 2019 爆炸记&题解

谁说胖子不能爱 提交于 2019-12-05 09:13:08
考试状况 \(Day1\) \(8:30\) 解压,先打个含头文件和 \(freopen\) 的模板程序,准备做题。 \(8:35\) 开题,心想着按顺序做吧,毕竟难度一般是按顺序排的。 第一题,一眼看过去。 标题:格雷码 描述:格雷码是 \(balabala\) ,有个方法可以生成格雷码 \(balabala\) 数据范围: \(long\ long\) 内 求 \(n\) 位格雷码第 \(k\) 项?第一位看一下在前半还是后半,第二位递归下去……复杂度 \(O(n)\) ,没什么大问题,直接开打。 \(8:45\) 打完了,测小样例、大样例,手造两个小数据,测一下极限数据……等等,极限数据是 \(63\) 还是 \(64\) 位?看一下数据范围, \(n<=64\) ,可以等于……那就不能用 \(long\ long\) 了,赶紧改成 \(unsigned\ long\ long\) ,发现不知道怎么读入……改成 \(cin\) 。测一下最大数据,能过,好的下一道。 \(8:50\) 第二题好像蛮套路的,树上做合法括号序列……考虑到括号序列的合法判断,只需要把 \((\) 当成 \(1\) , \()\) 当成 \(-1\) ,求前缀和,满足没有任何一个位置小于 \(0\) ,并且最后的位置等于 \(0\) 就一定合法。那么考虑在树上 \(Dfs\) 维护前缀和,统计方案

Vim: How can I create a file after “$ vim file.tgz”?

南楼画角 提交于 2019-12-05 07:28:21
问题 I want to create a file to tarball, without explicitly opening/extracting it but directly by using Vim. Is that possible? $ vim file.tgz :e someNewfile :w! # how can I create here a file? 回答1: Vim handles tar and derived files (including .tgz) using a vimscript called tar.vim . You can see tar.vim 's documentation by typing :help tar<CR> inside vim. According to that documentation: When one edits a *.tar file, this plugin will handle displaying a contents page. Select a file to edit by moving

linux centos7下源码 tar安装mysql5.7.22或mysql5.7.20 图文详解

北城以北 提交于 2019-12-05 06:44:55
之前用的rpm安装的每次安装都是最新的,,,导致每次版本不统一。。。 现在用tar包安装5.7.22和5.7.20一样的 5.7.20之后的和之前的版本还是有点不一样的 官网地址 https://dev.mysql.com/downloads/mysql/ 1. 安装依赖 yum install -y cmake make gcc gcc-c++ libaio ncurses ncurses-devel cd /usr/local/src 链接:https://pan.baidu.com/s/18tSRnB7FBb7Ak9Sr665Jeg 密码:86nj 这是5.7.22版本,下载上传到服务器 wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz(不能下载了) 如果上面链接不能下载,去官网找,下面的步骤都一样 wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz(用这个,后续的步骤都一样) 解压 tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz 将解压的复制到 /usr

How do I compress a folder with the Python GZip module?

自古美人都是妖i 提交于 2019-12-05 05:58:00
I'm creating Python software that compresses files/folders... How would I create a section of the code that asks for the user input of the folder location and then compresses it. I currently have the code for a single file but not a folder full of files. Please explain in detail how to do this. The code to compress a folder in to tar file is: import tarfile tar = tarfile.open("TarName.tar.gz", "w:gz") tar.add("folder/location", arcname="TarName") tar.close() It works for me. Hope that works for you too. GZip doesn't do compression of folders/directories, only single files. Use the zipfile

linux 压缩与解压缩命令

余生颓废 提交于 2019-12-05 05:28:04
tar 解压:tar xvf FileName.tar 压缩:tar cvf FileName.tar .gz 解压1:gunzip FileName.gz 解压2:gzip -d FileName.gz 压缩:gzip FileName .tar.gz 解压:tar zxvf FileName.tar.gz 压缩:tar zcvf FileName.tar.gz .bz2 解压1:bzip2 -d FileName.bz2 解压2:bunzip2 FileName.bz2 压缩: bzip2 -z FileName .tar.bz2 解压:tar jxvf FileName.tar.bz2 压缩:tar jcvf FileName.tar.bz2 DirName .bz 解压1:bzip2 -d FileName.bz 解压2:bunzip2 FileName.bz .tar.bz 解压:tar jxvf FileName.tar.bz .Z 解压:uncompress FileName.Z 压缩:compress FileName .tar.Z 解压:tar Zxvf FileName.tar.Z 压缩:tar Zcvf FileName.tar.Z .tgz 解压:tar zxvf FileName.tgz .tar.tgz 解压:tar zxvf FileName.tar

Postgres Tutorial: pg_restore: [archiver] input file does not appear to be a valid archive

有些话、适合烂在心里 提交于 2019-12-05 05:18:42
I'm working through the Postgres DVD tutorial and am running into issues importing their sample database. Running pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar.gz gives me pg_restore: [archiver] input file does not appear to be a valid archive . My process so far has been the following: Download the dvdrental.zip file Extract it to a .tar using tar czf dvd-database.tar.gz dvdrental.zip (I've also tried extracting the zip to a folder first with the same result, as well as dropping the .gz) Running pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar as stated

linux命令2

自古美人都是妖i 提交于 2019-12-05 03:16:48
最近在项目中用到了Linux,然后自己只会那些简单的,发现头用的溜溜的,所以查了一下常用的命令,多查,多用。 系统信息 arch 显示机器的处理器 架构 (1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS / DMI) hdparm -i /dev/hda 罗列一个磁盘的架构特性 hdparm -tT /dev/sda 在磁盘上执行测试性读取操作 cat /proc/cpuinfo 显示CPU info的信息 cat /proc/interrupts 显示中断 cat /proc/meminfo 校验内存使用 cat /proc/swaps 显示哪些swap被使用 cat /proc/version 显示内核的版本 cat /proc/net/dev 显示网络适配器及统计 cat /proc/mounts 显示已加载的文件系统 lspci -tv 罗列 PCI 设备 lsusb -tv 显示 USB 设备 date 显示系统日期 cal 2007 显示2007年的日历表 date 041217002007.00 设置日期和时间 - 月日时分年.秒 clock -w 将时间修改保存到 BIOS 关机 (系统的关机、重启以及登出 ) shutdown -h now 关闭系统(1)

find with xargs and tar

断了今生、忘了曾经 提交于 2019-12-05 02:23:57
I have the following I want to do: find . -maxdepth 6 ( -name *.tar.gz -o -name bediskmodel -o -name src -o -name ciao -o -name heasoft -o -name firefly -o -name starlink -o -name Chandra ) -prune -o -print| tar cvf somefile.tar --files-from=- i.e. exclude a whole lot of stuff, only look to 6 subdirs depth, and then once pruning is done, tar up the rest. Not hard. The bit before the pipe (|) works 100%. If I exclude the tar, then I get what I'm after (to the screen). But once I include the pipe, and the tar, it tars everything, including all the stuff I've just excluded in the find. I've tried

Python: Extract using tarfile but ignoring directories

冷暖自知 提交于 2019-12-05 00:05:45
If I have a .tar file with a file '/path/to/file.txt' , is there a way (in Python) to extract the file to a specified directory without recreating the directory '/path/to' ? I meet this problem as well, and list the complete example based on ekhumoro's answer import os, tarfile output_dir = "." tar = tarfile.open(tar_file) for member in tar.getmembers(): if member.isreg(): # skip if the TarInfo is not files member.name = os.path.basename(member.name) # remove the path by reset it tar.extract(member,output_dir) # extract The data attributes of a TarInfo object are writable. So just change the

Python解压 rar、zip、tar文件

梦想的初衷 提交于 2019-12-04 23:48:28
Q1 :如何解压 rar 压缩包文件? A : - Step1:检查是否有 rarfile 第三方库,若没有该模块,则需要进行安装 ; - Step2:参考代码如下: import rarfile import os rar=rarfile.RarFile(filename, mode='r') # mode的值只能为'r' # 判断同名文件夹是否存在,若不存在则创建同名文件夹 if os.path.isdir(os.path.splitext(filename)[0]): rf_list = rf.namelist() # 得到压缩包里所有的文件 print('rar文件内容', rf_list) else: os.mkdir(os.path.splitext(filename)[0]) rar.extractall(os.path.splitext(filename)[0]) # 解压文件 rar.close() # 关闭文件,必须有,释放内存 Q2 :如何解压 zip 压缩包文件? A: 可以使用RPA设计器自带的【zip 解压】组件,编写代码,则可以参考如下(注意检查是否 zipfile 第三方库,设计器自带,可直接调用): import zipfile import os zip_file = zipfile.ZipFile(filename) if os.path