Articles of 脚本

如何使用find命令清除所有文件的内容

是否有一个简单的步骤来清除使用find命令的所有“.log”文件的内容。 目前我使用“echo -n> filename.log”我已经尝试echo -n> /var/application-logs/*.log,但它不工作.. 有没有更好的方法来清除多个文件的内容?

如何编写一个脚本来安装多个东西,只要执行它

我有一台服务器(centOS),我想安装staple开发工具。 Java,Tomcat和MySql。 编写一个可以在新生成的服务器上运行的脚本的好方法是什么,以便在每个新服务器上都不要手动完成。 一个bash脚本最适合这个目的吗? 我希望这个脚本不仅可以绑定到centOS,还可以在不同的linux下工作

不能将NGinx版本存储到variables

这似乎是一个愚蠢的问题,但我似乎无法将nginx -v输出存储到一个variables,甚至写在bash中的文件。 php –version和mysql –version似乎工作正常,但Nginx不会保存。 有没有办法做到这一点。 我在尝试: NGINX_VERSION=$(nginx -v) nginx -v > /home/user/nginxversion.txt PHP以相同的方式正常工作,但nginx不会保存。 PHP_VERSION=$(php –version) php -v > /home/user/phpversion.txt

一旦find另一个string就replace一个string

我以编程方式构build框,但我需要更新PHP的.repo文件,它具有以下内容: # Repository: http://rpms.remirepo.net/ # Blog: http://blog.remirepo.net/ # Forum: http://forum.remirepo.net/ [remi] name=Remi's RPM repository for Enterprise Linux 6 – $basearch #baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/ mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi [remi-php55] name=Remi's PHP 5.5 RPM repository for Enterprise Linux 6 – $basearch #baseurl=http://rpms.remirepo.net/enterprise/6/php55/$basearch/ mirrorlist=http://rpms.remirepo.net/enterprise/6/php55/mirror # NOTICE: common dependencies are in "remi-safe" enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi [remi-php56] name=Remi's PHP 5.6 RPM repository […]

新手系统pipe理员 – Bash脚本协助

我是一个正在学习angular色的新系统pipe理员。 我在这里有一个bash脚本,我无法工作。 这只是一个testing脚本作为我的第一个,所以我知道设置authorized_keys到777是不明智的,但我只是做它来检查我的脚本是否现在工作。 我正在使用LDAP的密码,所以用SSH密钥远程设备是不理想的,所以我使用SSH通行证。 此代码工作到useradd,然后它不mkdir .ssh,不触摸/创buildauthorized_keys,并不会更改文件的权限。 为什么? #!/bin/bash -x username="test" echo Enter server IP: read server sshpass -p randompassword ssh myusername@$server sudo -i 'useradd test1; echo $username user added, press any key to continue; read; sudo -i; mkdir /home/test1/.ssh; cd /home/test1/.ssh; touch authorized_keys; chmod 777 authorized_keys' 我可能不了解有关bash脚本正确的东西,但所有这些命令需要在远程机器上运行。

在命令中用括号批量循环

我有以下代码的batch file: for /f "tokens=*" %%a in ('dir /b /a-d') do ( echo Processing %%a >>%LOG% dtsrun /S(local) /NNotesLoad /A"FilePath:8="%NOTESDIR%\%%a" /AClientID=%1 >>%LOG% echo Deleting %%a >>%LOG% del %%a /q ) 这是返回“/ NNotesLoad在这个时候是意外的”错误消息,因为第二个括号有效closuresFOR块。 我必须离开(本地)作为/ S参数。 我如何逃避dtsrun行中的括号?

创build一个batch file,删除所有用户和默认用户以外的所有用户数据文件夹?

我正在使用Windows XP,并希望创build一个batch file,删除All Users和Default User以外的所有用户数据文件夹。 我怎样才能做到这一点?

Linux在文件和子目录中search

正确的需要一个脚本/命令,将列出所有.p​​hp文件,其中有一个模式/string。 它应该查看当前目录和所有子目录。 如果显示的行号是这样的,那就更好了: my new command ./www/index.php Line 12 ./www/lib/config.php Line 123 也有可能做一个search和replace每个文件中有这种模式的行?

如何写脚本打印取消注释行

我有一个非常长的configuration文件几乎没有评论和取消注释行现在,我想要打印出行取消注释 # LOCAL PATHNAME INFORMATION # # The queue_directory specifies the location of the Postfix queue. # This is also the root directory of Postfix daemons that run chrooted. # See the files in examples/chroot-setup for setting up Postfix chroot # environments on different UNIX systems. # queue_directory = /var/spool/postfix # The command_directory parameter specifies […]

百胜 – testing是否安装了某些东西,然后使用Bash脚本

有没有一种很好的方法来使用Yum来testing是否安装了某些东西(true为false),然后在Bash脚本中使用该答案?