我需要cron一个bash应该拆分文件大于50 GB在一个特定的目录(而不是recursion)在Linux中。 有人能指导我吗? 喜欢: find . -maxdepth 1 -type f -size +49G -exec ls -lh {} \; 我怎样才能发送每个文件名拆分命令作为参数? split –bytes=30G $filenameoffoundfile $filenameoffoundfile
我有文字,包含一些行。 所以,我需要做几行GREP。 例如,我有重复的文字,我应该GREP得到线,有这个重复的关键词。 grep -o "test|test2" textfile 我的文字: 123|never for your|test 123421|never for your|test2 123412|never for your|test3 12341|never for your|test4 12311|never for your|test2 123312312|never for your|test 123321312|never for your|test2 我应该: 123|never for your|test 123421|never for your|test2 123312312|never for your|test 123321312|never for your|test2 它的工作,但它不工作,我想要的。 它在文本中search所有单词“test”和“test2”。 但是我想得到的文本块,就像一些模式,只有在“testing”来到“test2”之后。 你有什么想法吗?
在一个运行Unix的路由器上,我希望使监视所有传出的数据包,这些数据包我想临时白名单IP地址我连接到,发送和接收。 基本上在防火墙中创build一个针孔,通常会丢弃所有传入的数据包(丢弃除白名单之外的所有数据包,这些数据包是基于我发送数据包连接的此脚本列出的白名单)。 在环顾四周,我可以做一个基于封包嗅探器的bash脚本,但有没有办法在iptables本身,而不必涉及包嗅探器和bash脚本?
我正在写温度,CPU负载和内存数据到rrdtool表,更新我使用N为了打发时间,但是有一个问题,暂时rest。 非法尝试更新使用时间1487152126当最后一次更新时间是1487212862(最小一秒钟的步骤)这是一个相当的时间差,我不知道为什么它会那么遥远。 任何帮助都很好 – 昨天工作得很好,所以不知道哪里出了问题。 更新function: #!/bin/bash cd /temptest/ TEMPERATURE=$(/opt/vc/bin/vcgencmd measure_temp | sed 's/[^0-9]*//g') TEMPERATURE=$(echo $TEMPERATURE | sed 's/.$/.&/') CPULOAD=$(top -d 0.5 -b -n2 | grep "Cpu(s)"|tail -n 1 | awk '{print $2 +$4}') PIMEM=$(free -h | grep "Mem:" | awk '{print $4}') PIMEM=$(echo $PIMEM | sed 's/[^0-9]*//g') PIMEMTOTAL=$(free -h | grep "Mem:" | awk […]
我有一个命令,把域名作为选项。 我有很长的域名列表,所以我想自动parsing这个域列表到命令中。 例如,最简单的用法是command –option=example-one.com –output=file.ext 。 添加域列表后,最终要执行的命令看起来像command –option=example-one.com … –option=example-99.io –output=file.ext (其中'…'将会有97个更多的选项,在这里缩略显示) 这是可能在Bash做,如果是的话,请问是什么? 以下是我尝试过的方法: command –option=$(cat domains.txt) –output=file.ext command "$(while read baddomains ; do echo -n '–option=$baddomains ' ; done < domains.txt)" –output=file.ext command –option="domains.txt" –output=file.ext 该命令while read baddomains ; do echo -n '–option=$baddomains ' ; done < domains.txt > all-options.txt while read baddomains ; […]
使用ACL为非root用户提供对根目录的访问权限 – 作为root- mkdir /testdir chmod 0400 /testdir setfacl -dm u:mike:rwx /testdir getfacl /testdir # file: testdir # owner: root # group: root user::r– group::— other::— default:user::r– default:user:mike:rwx default:group::— default:mask::rwx default:other::— 正如mike- ls -la /testdir ls: cannot open directory '/testdir': Permission denied selinux已启用。 我在审计日志中find否认,但没有find任何,虽然我无法想象selinux不是拒绝的原因。 我只是想保持这个文件夹远离每个人,除了一个用户迈克,所以我怎么能debugging呢?
我正在运行命令: ps -ef | grep [p]ts/1 ps -ef | grep [p]ts/1 结果是: root 13820 1733 0 14:19 ? 00:00:00 sshd: root@pts/1 root 13822 13820 0 14:19 pts/1 00:00:00 -bash root 15847 13822 0 15:32 pts/1 00:00:00 ps -ef root 15848 13822 0 15:32 pts/1 00:00:00 grep [p]ts/1 为什么它返回grep和ps ? PS单引号和双引号给了我相同的结果。 我能够使用grep -v grep工作得到没有“grep”的输出,但我想用更优雅的方式。
我有2个文件: 2 m1.small 1 m3.large 2 m3.medium 2 t1.micro 1 t2.large 7 t2.medium 4 t2.micro 7 t2.small 和b: 1 c4.2xlarge 1 c4.large 2 m1.small 1 m3.large 3 m3.medium 1 m4.large 3 t1.micro 3 t2.large 11 t2.medium 7 t2.micro 7 t2.small 当我使用sdiff时,我得到了所有不同的结果: $ sdiff ab 2 m1.small | 1 c4.2xlarge 1 m3.large | 1 c4.large 2 […]
我正在部署我们的LetsEncrypt SSL证书。 我有每天运行的cron作业,如果需要使用certbot更新certificatse。 我也有一个将证书部署到负载平衡器的脚本。 当证书更新时,Certbot会有一个部署callback。 Certbot将在更新证书后立即致电我的脚本。 这似乎工作正常 – 主要是。 但是,如果部署因任何原因失败,我希望在第二天再次尝试。 它看起来没有任何内置于certbot的function。 我如何实现具有以下逻辑的脚本: if [ /etc/letsencrypt/live/example.com/cert.pem != certfrom https://example.com/ ] then example.com-cert-deploy.sh fi
我知道这已经被问过,但我正努力确定错误的根本原因与我的脚本。 我经历了其他问题,并试图转换(切换/ \为@),但它只是不起作用,我仍然得到相同的错误? 只要我在最后4(从底部)joinexpression式,我开始得到错误,.. 当我运行这个 clustername="'XXXCluster'" seed=xx.xxx.xxx.xx ip=xx.xxx.xxx.xx hint="/opt/cassandra/data/hints" data="/opt/cassandra/data/data" commitlog="/opt/cassandra/data/commitlog" cache="/opt/cassandra/data/saved_caches" sed -i -e "s/\(cluster_name:\).*/\1$clustername/" \ -e "s/\(- seeds:\).*/\1$seed/" \ -e "s/\(listen_address:\).*/\1$ip/" \ -e "s/\(rpc_address:\).*/\1$ip/" \ -e "s/\(broadcast_rpc_address:\).*/\1$ip/" \ -e "s/\(hints_directory:\).*/\1$hint/" \ -e "s/\(data_file_directory:\).*/\1$data/" \ -e "s/\(commitlog_directory:\).*/\1$commitlog/" \ -e "s/\(saved_caches_directory:\).*/\1$cache/" /opt/cassandra.yaml 我得到这个sed:-eexpression式#6,字符29:未知选项's' 但我不能看到如何解决这个问题,有人可以帮我吗? 提前致谢..