#!/bin/shell
filename[0]="graphics_k.c"
filename[1]="image_k.c"
filename[2]="pipeline_info_ctrl.c"
filename[3]="pipeline_op_ctrl.c"
filename[4]="pl_audio.c"
filename[5]="pl_audio.h"
filename[6]="pl_video.c"
filename[7]="pl_video.h"
filename[8]="pm_device.c"
filename[9]="pm_surface_internal.c"
filename[10]="pm_device.c"
filename[11]="vpmfb.c"
filename[12]="pipeline_manager.h"
filename[13]="pl_tuner.c"
filename[14]="pl_tuner.h"
filename[15]="pnx8400_a9_env.sh"
sourcefile_path[0]="$NXP_BASE_ROOT/target/src/sd/video/lnxDrv/comps/lnxtmvssIO/src"
sourcefile_path[1]="$NXP_BASE_ROOT/target/src/sd/video/lnxDrv/comps/lnxtmvssIO/src/"
sourcefile_path[2]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrPipeline/src/"
sourcefile_path[3]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrPipeline/src/"
sourcefile_path[4]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrPipeAudio/src/"
sourcefile_path[5]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrPipeAudio/inc/"
sourcefile_path[6]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrPipeVideo/src/"
sourcefile_path[7]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrPipeVideo/inc/"
sourcefile_path[8]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrVideoPres/src/"
sourcefile_path[9]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrVideoPres/src/"
sourcefile_path[10]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrVideoPres/src/"
sourcefile_path[11]="$NXP_BASE_ROOT/target/src/sd/celf/drivers/comps/vpmfbDrv/src/"
sourcefile_path[12]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrPipeline/inc/"
sourcefile_path[13]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrPipeTuner/src/"
sourcefile_path[14]="$NXP_BASE_ROOT/target/src/sd/pvr/drivers/comps/tmpvrPipeTuner/inc/"
sourcefile_path[15]="$NXP_BASE_ROOT/"
patchfile_path="$NXP_BASE_ROOT/../PATCH/"
backupfile_path="$NXP_BASE_ROOT/../PATCH/backup/"
#/bin/echo $sourcefile
#/bin/echo $pathchfile
#/bin/echo $backupfile
function overlay
{
for (( i = 0; i < 16 ; i ++ ))
do
sourcefile=${sourcefile_path[$i]}${filename[$i]}
pathchfile=$patchfile_path${filename[$i]}
backupfile=$backupfile_path${filename[$i]}
if [ -e $sourcefile ]
then
/bin/echo "$sourcefile file exit!"
if [ -e $backupfile ]
then
/bin/echo "Backup file exit! Ignore it..."
else
/bin/echo "Backup file now..."
cp -f $sourcefile $backupfile
fi
/bin/echo "Overlay file..."
cp -f $pathchfile $sourcefile
else
/bin/echo "Source file not exit!Pls check the source path"
fi
done
}
function restore
{
for (( i = 0; i < 16 ; i ++ ))
do
sourcefile=${sourcefile_path[$i]}${filename[$i]}
pathchfile=$patchfile_path${filename[$i]}
backupfile=$backupfile_path${filename[$i]}
if [ -e $sourcefile ]
then
/bin/echo "$sourcefile file exit! restore it..."
if [ -e $backupfile ]
then
/bin/echo "Restore file now..."
cp -f $backupfile $sourcefile
/bin/echo "delete backup file..."
rm -f $backupfile
else
/bin/echo "Backup file missing,please check..."
fi
else
/bin/echo "Source file not exit!Pls check the source path"
fi
done
}
if [ -z $NXP_BASE_ROOT ] ; then
/bin/echo "NXP_BASE_ROOT Missing,Please run setup.sh first!"
return
fi
/bin/echo "Huangpu application, overlay below files"
if [ x$1 == x ]
then
/bin/echo "Overlay script for Huangpu application!"
/bin/echo "Useage:"
/bin/echo "patch overlay: overlay the patch files and backup the source files"
/bin/echo "patch restore: restore the source files and delete all backup files"
return
else
case "$1" in
overlay)
/bin/echo "overlay"
overlay
;;
restore)
/bin/echo "restore"
restore
;;
*)
/bin/echo "Overlay script for Huangpu application!"
/bin/echo "Useage:"
/bin/echo "patch overlay: overlay the patch files and backup the source files"
/bin/echo "patch restore: restore the source files and delete all backup files"
;;
esac
fi
但是其实可以用一句话就实现以上的功能:
find -name "*.[ch]" -exec cp -rf {} ../../SRC/{} \;
7. 产生一个全0xFF, 0xA5, 0xAA 的文件
tr '\000' '\377' < /dev/zero| dd of=file_0xFF.bin bs=2k count=1
tr '\000' '\245' < /dev/zero| dd of=file_0xA5.bin bs=2k count=1
tr '\000' '\252' < /dev/zero| dd of=file_0xAA.bin bs=2k count=1
对一个文件后面不足大小的地方填充0
cat uldr.bin /dev/zero | dd bs=1 count=64k > uldr_padded_64k.bin
8. Find 命令对找到文件执行多个操作
find -name abc.txt -exec touch {} \; -exec ls -l {} \; -exec cat {} \;
9. Find 命令找两种以上的文件
find . \( -name "makefile" -o -name "*.patch" -o -name "*.txt" \)
10. 同时操作部分相同的文件或目录
touch test{0,1,2}
rm -f test{0,1,2}
mkdir -p test_dir/abc{1,2,3}
rm -rf test_dir/abc{1,3}
11. echo 代替键盘输入
echo -e “\n\n\n” 三个回车
从 AC_MGMT 中摘录的echo 代替键盘输入的 片段
18 useradd $AC_ID -g $GRP_ID -m && \
19 echo -e "$AC_ID\n$AC_ID\n"|passwd $AC_ID && \
20 echo "Create Successfully."
21 echo "Enabling Samba For $AC_ID..."
22 echo -e "$AC_ID\n$AC_ID\n$AC_ID\n"|smbpasswd -s -a $AC_ID && \
23 smbpasswd -e $AC_ID
24 echo "Samba Account for $AC_ID Done."
12. 合并文件
cat file1 file2 > file3
13. 找到所有ko并copy
cp $(find *.ko) to_dir
14. 暂停运行程序和恢复
CTRL-Z 暂停运行程序
jobs 查看当前任务列表
fg num 前台运行任务列表中 num 任务
bg num 后台运行任务列表中 num 任务
jacky@debian5:~$ ping 192.168.100.180
PING 192.168.100.180 (192.168.100.180) 56(84) bytes of data.
64 bytes from 192.168.100.180: icmp_seq=1 ttl=64 time=0.013 ms
64 bytes from 192.168.100.180: icmp_seq=2 ttl=64 time=0.005 ms
64 bytes from 192.168.100.180: icmp_seq=3 ttl=64 time=0.004 ms
^Z
[1]+ Stopped ping 192.168.100.180
jacky@debian5:~$ jobs
[1]+ Stopped ping 192.168.100.180
jacky@debian5:~$ ping 192.168.100.28
PING 192.168.100.28 (192.168.100.28) 56(84) bytes of data.
64 bytes from 192.168.100.28: icmp_seq=1 ttl=128 time=1.85 ms
64 bytes from 192.168.100.28: icmp_seq=2 ttl=128 time=0.216 ms
64 bytes from 192.168.100.28: icmp_seq=3 ttl=128 time=0.374 ms
^Z
[2]+ Stopped ping 192.168.100.28
jacky@debian5:~$ jobs
[1]- Stopped ping 192.168.100.180
[2]+ Stopped ping 192.168.100.28
jacky@debian5:~$
15. 无终端运行程序
a. nohup <command>
这样即便是shell被关闭,但是执行的命令仍然会继续执行。
b. 利用括号() 使进程成为 init(pid=1) 的子进程
(ping 192.168.0.1 &)
你可以用 ps -ef 看到 进程PID 和父进程PPID的变化
16.sed -i 'xxx' file
将文件定位在xxx之前,然后你可以用echo换掉接下来的内容
17.如果你想在脚本文件中暂停
read -n1 -p "Press any key to continue..."