日期:2014-05-16  浏览次数:20668 次

请问个cat命令的问题
cat ${cfgfile} | sed -e /filename=system.img/d -e /filename=yaffs2_gnu_system.img/d -e s/size=734003200/size=${rootfs_size}/ -e s/size=471859200/size=${rootfs_size}/ -e s/filename=flashboot.img/filename=boot.img/ > flash.cfg;

请问这句命令的作用是?

请教各位大侠了



------解决方案--------------------
大概是这样,打开${cfgfile}这个变量指向的文件,然后替换里面的一些字符项,然后再写入到flash.cfg中;
------解决方案--------------------
Assembly code

[freebsd:~/shcode ]$cat temp.txt 
filename=system.img
filename=yaffs2_gnu_system.img
size=734003200
size=471859200
filename=flashboot.img

[freebsd:~/shcode ]$cat sh901.sh
cfgfile=temp.txt
rootfs_size=11111
cat ${cfgfile} | sed -e /filename=system.img/d -e /filename=yaffs2_gnu_system.img/d -e s/size=734003200/size=${rootfs_size}/ -e s/size=471859200/size=${rootfs_size}/ -e s/filename=flashboot.img/filename=boot.img/ > flash.cfG
[freebsd:~/shcode ]$chmod u+x sh901.sh
[freebsd:~/shcode ]$./sh901.sh
[freebsd:~/shcode ]$ls
flash.cfG    sh900.sh    sh901.sh    temp.sh        temp.txt
[freebsd:~/shcode ]$cat flash.cfG 
size=11111
size=11111
filename=boot.img

------解决方案--------------------
自己新建个文件试一下就知道了:

Assembly code

[freebsd:~/shcode ]$cat temp.txt 
filename=system.img aa
filename=yaffs2_gnu_system.img aa
size=734003200
size=471859200
filename=flashboot.img  aa

[freebsd:~/shcode ]$cat sh901.sh 
cfgfile=temp.txt
rootfs_size=11111
cat ${cfgfile} | sed -e /filename=system.img/d -e /filename=yaffs2_gnu_system.img/d -e s/size=734003200/size=${rootfs_size}/ -e s/size=471859200/size=${rootfs_size}/ -e s/filename=flashboot.img/filename=boot.img/ > flash.cfG
[freebsd:~/shcode ]$./sh901.sh
[freebsd:~/shcode ]$cat flash.cfG
size=11111
size=11111
filename=boot.img  aa