Linux

Linux bash script to find and delete oldest file with special characters and whitespaces in a directory tree if condtion is met

北慕城南 提交于 2021-02-20 00:43:19
问题 I need some help building a linux bash script to find and delete oldest file with special characters and white spaces in a directory tree if condtion is met. I have been searching the forum for questions like this and thanks to users here I came with output as seen under. So far I can't figure out how to pipe the output filename to rm, so that it is being deleted. The goal is to check if hdd is running full, and if so delete the oldest file until free-space requirement is met. The problem is,

Text Encoding between Linux and Windows

一世执手 提交于 2021-02-20 00:15:19
问题 The main question I have is how can I get a textfile that I have in Linux to display properly in PowerShell. In Linux, I have text files with some special characters, and in fact Notepad displays the text file exactly as it is displayed in Linux: Unfortunately, my program prints to my Linux Terminal, and thus I need the same output in my Windows terminal. I have seen through other answers that I need to use a TrueType font, so I am using Lucidia Console on my Linux device, the encoding is UTF

Text Encoding between Linux and Windows

拥有回忆 提交于 2021-02-20 00:14:54
问题 The main question I have is how can I get a textfile that I have in Linux to display properly in PowerShell. In Linux, I have text files with some special characters, and in fact Notepad displays the text file exactly as it is displayed in Linux: Unfortunately, my program prints to my Linux Terminal, and thus I need the same output in my Windows terminal. I have seen through other answers that I need to use a TrueType font, so I am using Lucidia Console on my Linux device, the encoding is UTF

每天学一个 Linux 命令(39):tar

主宰稳场 提交于 2021-02-19 20:54:13
点击下方“ 民工哥技术之路 ”,选择“设为星标” 回复“ 1024 ”获取独家整理的学习资料! 昨日推荐: 每天学一个 Linux 命令(38):vi/vim 命令简介 tar 命令用于打包、压缩与解压压缩包文件。 tar 命令常常用于打包、压缩某些文件或目录,也可以添加新文件到归档文件中。Tar 代表的是磁带存档,是一种归档的文件格式,早期用于将文件归档到磁带备份存储。现可以用于收集、分发、归档文件,还可以保留文件原有的属性,如:用户和组权限,访问和修改日期以及目录结构。 语法格式 tar [OPTIONS] [FILE] 选项说明 -A #新增文件到已经存在的归档文件 -B #设置区块大小 -c #建立新的归档文件 -C #将压缩的文件解压到指定的目录下 -d #记录文件的差异 -x #解压或提取归档文件内容 -t #列出备份文件的内容 -z #通过gzip命令来压缩/解压缩文件,文件名一般为 xx.tar.gz -Z #通过compress命令处理备份文件 -f #指定备份文件 -v #显示命令执行过程 -r #添加新文件到已经压缩的文件中 -u #添加改变了和现有的文件到已经存在的压缩文件 -j #通过bzip2命令来压缩/解压缩文件,文件名一般为xx.tar.bz2 -v #显示操作过程; -k #保留原有文件不覆盖 -m #保留文件不被覆盖 -w #确认压缩文件的正确性

Linux小技巧--指定用户执行命令

僤鯓⒐⒋嵵緔 提交于 2021-02-19 17:09:16
之前找了一些博客,但是在执行的时候一直报错,后来参考这篇博客( https://www.cnblogs.com/bodhitree/p/6018369.html )才发现没有加引号 su 用户 -c "你要执行的命令" 本文转载自 https://www.cnblogs.com/bodhitree/p/6018369.html 。 本文综合分析了Linux系统下,如何使用runuser命令、su命令和sudo命令以其他用户身份来运行程序,以及这三个命令的运行效率比较。 一、su 命令临时切换用户身份 SU:( Switch user切换用户),可让一个普通用户切换为超级用户或其他用户,并可临时拥有所切换用户的权限,切换时需输入欲切换用户的密码;也可以让超级用户切换为普通用户,临时以低权限身份处理事务,切换时无需输入欲切换用户的密码。 在 Linux 系统中,有时候普通用户有些事情是不能做的,除非是 root 用户才能做到。这时就需要用 su 命令临时切换到 root 身份来做事了。 1、su 的语法 su [OPTION选项参数] [用户] -, -l, –login 切换用户时,使环境变量(home,shell,user,logname,path等)和欲切换的用户相同、不使用则取得用户的临时权限,不加载环境变量。用su命令切换用户后,可以用 exit 命令或快捷键[Ctrl+D

SSH面密码登录

老子叫甜甜 提交于 2021-02-19 12:13:40
1.检查所有机器的openssh是否正常安装 2.使用命令 ssh-keygen -t rsa 生成id_rsa和id_rsa.pub密钥和公钥 三次回车(三次回车表示生成的文件默认地址~/.ssh和无密码登录) 3.进入到~/.ssh/目录下 cat id_rsa.pub >>authorized_keys 4.使用scp命令将authorized_keys复制到其它的机器~/.ssh/目录下即可 注: 1.如果其它机器上无.ssh目录,可能是安装openssh后没有执行过ssh命令 2.若想实现服务器之间的互相SSH无密码登录,执行命令 2 ,然后执行下面的命令将公钥追加到其它机器的authorized_keys文件中: cat ~/.ssh/id_dsa.pub | ssh 192.168.0.107 'cat - >> ~/.ssh/authorized_keys' 来源: oschina 链接: https://my.oschina.net/u/2924397/blog/750874

getline() is repeatedly reading the file, when fork() is used

和自甴很熟 提交于 2021-02-19 11:01:42
问题 I am developing a simple shell program, a command line interpreter and I wanted to read input from the file line by line, so I used getline() function. At the first time, the program works correctly, however, when it reaches the end of the file, instead of terminating, it starts to read a file from the start and it runs infinitely. Here are some codes in main function that are related to getline(): int main(int argc,char *argv[]){ int const IN_SIZE = 255; char *input = NULL; size_t len = IN

getline() is repeatedly reading the file, when fork() is used

白昼怎懂夜的黑 提交于 2021-02-19 10:55:37
问题 I am developing a simple shell program, a command line interpreter and I wanted to read input from the file line by line, so I used getline() function. At the first time, the program works correctly, however, when it reaches the end of the file, instead of terminating, it starts to read a file from the start and it runs infinitely. Here are some codes in main function that are related to getline(): int main(int argc,char *argv[]){ int const IN_SIZE = 255; char *input = NULL; size_t len = IN

getline() is repeatedly reading the file, when fork() is used

白昼怎懂夜的黑 提交于 2021-02-19 10:50:13
问题 I am developing a simple shell program, a command line interpreter and I wanted to read input from the file line by line, so I used getline() function. At the first time, the program works correctly, however, when it reaches the end of the file, instead of terminating, it starts to read a file from the start and it runs infinitely. Here are some codes in main function that are related to getline(): int main(int argc,char *argv[]){ int const IN_SIZE = 255; char *input = NULL; size_t len = IN

MySQL学习【SQL语句上】

守給你的承諾、 提交于 2021-02-19 10:48:31
1.连接服务端命令 1.mysql -uroot -p123 -h127.0.0.1 2.mysql -uroot -p123 -S /tmp/mysql.sock 3.mysql -uroot -p123 -hlocalhost 4.mysql -uroot -p123 2.mysql登陆后的一些命令 1.\h或者help   查看帮助 2.\G       格式化查看数据(以key:value形式) 3.\T 或 tee    记录日志 4.\c       结束命令 5.\s或者status  查看状态信息 6.\. 或者source  导入sql数据 7.\u 或use    使用数据库 8.\q或exit或quit  退出 3.mysqladmin的一些使用 1.查看mysql存活状态 [root@db01 ~]# mysqladmin -uroot -p123 ping 2.查看mysql状态信息 [root@db01 ~]# mysqladmin -uroot -p123 status 3.关闭mysql进程 [root@db01 ~]# mysqladmin -uroot -p123 shutdown 4.查看mysql参数 [root@db01 ~]# mysqladmin -uroot -p123 variables 5.删除数据库 [root@db01 ~]#