SHELL 文件处理

参数:
-f:检查是否存在,且为文件;
-d:检查是否存在,且为文件夹;
-x:检查是否存在,且可执行;
例如:
文件名存在为真: if [ -f <变量> ]
                             then
文件名不存在为真:if ! [-f <变量>]
                                then

逐行读文件
#! /bin/bash

IFS="
"

for LINE in `cat /tmp/1.txt`
do
        echo $LINE
done


#! /bin/bash

IFS="
"

cd /etc/httpd/conf.d/proxy

for LINE in `cat /tmp/filelist.txt`
do
        echo "<Location /$LINE/>" > Proxy$LINE.conf
        echo -e "\tProxyPass http://<IP address>/$LINE/" >> Proxy$LINE.conf
        echo -e "\tProxyPassReverse http://<IP address>/$LINE/" >> Proxy$LINE.conf
        echo "</Location>" >> Proxy$LINE.conf
done

Comments

Popular posts from this blog

Linux RHCE Preparation

Nginx Proxy & Load Balance & LNMP

Snort+barnyard2+Snorby CentOS 6.5_64 Installation