linux相关的一些记录
1.压缩相关
1> tar.gz
解压:
1 | tar -zxvf file.tar.gz |
压缩:
1 | tar -zcvf file.tar.gz file1 file2 |
2> tar
解压:
1 | tar -xvf flie.tar |
压缩:
1 | tar -cvf file.tar file1 file2 |
3> zip:
解压:
1 | unzip file.zip |
压缩:
1 | zip -r file.zip file |
zip [参数] [压缩后的文件名] [被压缩文件名]
4> tar.bz2
解压:
1 | tar -jxvf file.tar.bz2 |
压缩:
1 | tar -jcvf file.tar.bz2 file1 file2 |
2.centos中文乱码
1 | vim /etc/locale.conf |
3.ssh连接自动断开
timed out waiting for input: auto-logout
Connection closing…Socket close.
1 | vim /etc/profile |
4.软连接建立
1 | ln -s /root/anaconda3/envs/py36/bin/python3.6 python |
ln –s 源文件 目标文件
5.硬连接建立
1 | ln /root/anaconda3/envs/py36/bin/python3.6 python |
6.linux删除文本中^M
I.^M引起原因:“\r”回车符
II.查看^M
1 | cat -A file.txt |
III.删除^M,^M不可复制,手动按出:ctrl+v+m
1 | cat file.txt | tr -d "^M" > newfile.txt |
IIII.批量处理
- 1). shell批量删除
1 | #!/bin/bash |
tips:
1
2
3
4#重命名
#newfile=`echo $file | sed "s/\([a-zA-Z0-9]\+\)\(.txt\)/\1-bak\2/"`
#syntax error near unexpected token `d
#shell文件有^M,需要先去掉;不能正其身,如正人何。2).批量验证
1 | #!/bin/bash |
- 3).java批量删除
1 | public class Test { |