linux 文件骚操作

如果快速查看一个文件的编码和属性
[root@localhost ~]# file RSA解密私钥.txt
RSA解密私钥.txt: ASCII text, with very long lines, with no line terminators

如何快速创建多层文件夹

mkdir -p 1/2/3

转换文件的编码

使用iconv命令

[root@localhost ~]# file RSA解密私钥.txt
RSA解密私钥.txt: UTF-8 Unicode text, with very long lines
[root@localhost ~]#
[root@localhost ~]# iconv RSA解密私钥.txt -t unicode -o rsa.txt
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# file rsa.txt
rsa.txt: Little-endian UTF-16 Unicode text, with very long lines
[root@localhost ~]# iconv RSA解密私钥.txt -t ascii -o rsa.txt
iconv: illegal input sequence at position 845
[root@localhost ~]# iconv RSA解密私钥.txt -t gb2312 -o rsa.txt
[root@localhost ~]# file rsa.txt
rsa.txt: ISO-8859 text, with very long lines

文件压缩相关

1、*.tar 用 tar –xvf 解压

2、*.gz 用 gzip -d或者gunzip 解压

3、.tar.gz和.tgz 用 tar –xzf 解压

4、*.bz2 用 bzip2 -d或者用bunzip2 解压

5、*.tar.bz2用tar –xjf 解压

6、*.Z 用 uncompress 解压

7、*.tar.Z 用tar –xZf 解压

8、*.rar 用 unrar e解压

9、*.zip 用 unzip 解压

高效的压缩可以考虑 gzip -9

将文件夹进行压缩(tar.gz)

 tar -vc -f fileSystem.tar.gz fileSystem

将文件进行压缩(*.zip)

zip abc.zip abc

将文件夹进行压缩(*.zip)

zip -r fileSystem.zip fileSystem

解压tar文件

tar -xvf git-2.4.3.tar

解压 *.tar.gz 文件

tar -xvf fileSystem.tar.gz

解压ZIP文件

unzip fileSystem.zip

查看*.tar.gz 文件

tar -tv -f fileSystem.tar.gz

查看*.zip 文件

unzip -v fileSystem.zip

除非标明,否则皆为<IT民工の在日生活 - 神户印象>原创之作,转载必须以明文链接标明出处。
本文链接:https://www.lifeinjp.net/share/linux/243

《linux 文件骚操作》有1条评论

发表评论