写了个脚本把编译好的ffmpeg的头文件和库复制到系统目录下

 感觉学shell得碰到啥问题现学现用,不专门去学。

#!/bin/sh

# directories
FAT="FFmpeg-iOS"
INSTALLLIBPATH="/usr/local/lib"
INSTALLINCLUDEPATH="/usr/local/include"

CWD=`pwd`
cd $FAT/lib
for LIB in *.a
do
   echo $LIB
   cd $CWD
   cp -rf $FAT/lib/$LIB $INSTALLLIBPATH/$LIB
done

cd $CWD
for dirlist in $(ls $FAT/include)
    do
       cp -rf $FAT/include/$dirlist $INSTALLINCLUDEPATH/$dirlist
       #cd ${dirlist}
       echo $FAT/include/${dirlist}
done
echo "ffmpeg install finished"

 

昨天发现cp -rf 复制jni.h会提示文件名太长,一长串的目录名加上jni.h,文件还是复制成功了。这个问题先留着。我把脚本改成挨个复制文件。shell脚本的格式要求真严格 if [ -d "$FAT/include/$dirlist" ]   这条语句这里if和[]之间要有空格 []这两边也要有空格,不然报错。另外在shell脚本中运行cp命令总出现No such file or directory ,我看了老外的讨论,按照他们的做法,运行成功了。cp有很多选项,覆盖选项,判断时间等选项的,但是我这里在测试不同版本的ffmpeg,干脆把文件夹和文件都删了再复制。

https://www.linuxquestions.org/questions/linux-newbie-8/cd-command-in-shell-script-returns-no-such-file-or-directory-927963/  cd command in shell script returns: No such file or directory

https://blog.csdn.net/qq_29175301/article/details/78413859

https://blog.csdn.net/zwlove5280/article/details/74016676

http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html

http://www.tldp.org/LDP/abs/html/ Advanced Bash-Scripting Guide

 

 

 

#!/bin/sh

 

# directories

FAT="FFmpeg-iOS"

INSTALLLIBPATH="/usr/local/lib"

INSTALLINCLUDEPATH="/usr/local/include"

 

CWD=`pwd`

cd $FAT/lib

for LIB in *.a

do

echo $LIB

#cp $FAT/lib/$LIB $INSTALLLIBPATH/$LIB

done

 

cd $CWD

for dirlist in $(ls $FAT/include)

do

if [ -d "$FAT/include/$dirlist" ]

then

if [ -e "$INSTALLINCLUDEPATH/$dirlist" ]

then

echo $INSTALLINCLUDEPATH/$dirlist && rm -rf $INSTALLINCLUDEPATH/$dirlist

fi

cd "$FAT/include/$dirlist" && echo "$FAT/include/${dirlist}"

dirName=$dirlist

mkdir $INSTALLINCLUDEPATH/$dirName

for file in $(ls *)

do

SRC=$FAT/include/$dirlist/$file

DEST=$INSTALLINCLUDEPATH/$dirName/${file}

cp ${file} ${DEST}

done

#cp -rf $FAT/include/$dirlist $INSTALLINCLUDEPATH/$dirlist

fi

cd $CWD

done

cd $CWD

pwd

echo "ffmpeg install finished"

 

https://www.jb51.net/article/48832.htm  这篇文章讲得不错 shell脚本递归遍历目录及子目录的例子分享

https://www.jb51.net/article/135168.htm

https://www.cnblogs.com/yinheyi/p/6648242.html

https://blog.csdn.net/dabokele/article/details/53933289

https://www.jb51.net/article/34332.htm

http://justcoding.iteye.com/blog/1943504 Linux常用Shell脚本珍藏

展开阅读全文

没有更多推荐了,返回首页