当前位置: 技术问答>linux和unix
linux命令行怎么读取文本做为命令?
来源: 互联网 发布时间:2017-02-28
本文导语: linux命令行怎么读取文本做为命令? 例如 /sss/bbb.txt的内容是 ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl=/usr --with-png-dir --with-jpeg-dir --with-freetype-dir --with-ic...
linux命令行怎么读取文本做为命令?
例如 /sss/bbb.txt的内容是
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl=/usr --with-png-dir --with-jpeg-dir --with-freetype-dir --with-iconv-dir=/usr/local --enable-gd-native-ttf --with-libxml-dir --with-zlib --with-mhash --with-mcrypt --with-ldap --with-ldap-sasl --with-curl=/usr/local --with-curlwrappers --enable-bcmath --enable-calendar --enable-mbstring --enable-ftp --enable-zip --enable-sockets --enable-exif --enable-zend-multibyte --enable-fpm --with-fpm-user=www --with-fpm-group=www make && make install
我想在命令行下,直接读取bbb.txt的内容,然后把它做为命令来执行
我在群里问了 有人说用eval 我试了试没成功
例如 /sss/bbb.txt的内容是
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl=/usr --with-png-dir --with-jpeg-dir --with-freetype-dir --with-iconv-dir=/usr/local --enable-gd-native-ttf --with-libxml-dir --with-zlib --with-mhash --with-mcrypt --with-ldap --with-ldap-sasl --with-curl=/usr/local --with-curlwrappers --enable-bcmath --enable-calendar --enable-mbstring --enable-ftp --enable-zip --enable-sockets --enable-exif --enable-zend-multibyte --enable-fpm --with-fpm-user=www --with-fpm-group=www make && make install
我想在命令行下,直接读取bbb.txt的内容,然后把它做为命令来执行
我在群里问了 有人说用eval 我试了试没成功
|
#! /bin/bash
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl=/usr --with-png-dir --with-jpeg-dir --with-freetype-dir --with-iconv-dir=/usr/local --enable-gd-native-ttf --with-libxml-dir --with-zlib --with-mhash --with-mcrypt --with-ldap --with-ldap-sasl --with-curl=/usr/local --with-curlwrappers --enable-bcmath --enable-calendar --enable-mbstring --enable-ftp --enable-zip --enable-sockets --enable-exif --enable-zend-multibyte --enable-fpm --with-fpm-user=www --with-fpm-group=www make && make install
将以上代码保存为filename.sh,保存在你要编译的目录下,也就是./configure文件所在的目录下
chmod +x filename.sh
然后./filename.sh
必须保证filename.sh和./configure在同一目录之下