新手求教一个关于awk的简单脚本
时间:2011-03-03
来源:互联网
#随机序列幻灯式演示, 关闭: 按两次 ALT+F4
#!/bin/bash
if [[ $# -lt 1 ]];then
echo 写入文件夹完整地址参数! 例:./prv.sh ~/Pictures/share/;
exit 0;
fi;
v_dir=$*;
if (echo $v_dir |grep -q '.*/.*');then
v_dir=$v_dir;
else
v_dir=$PWD;
fi;
if [[ ${v_dir:$((${#v_dir}-1)):1} != / ]];then
v_dir=$v_dir/;
fi;
v_picture_count=0;
for i in $(ls $v_dir);do
((v_picture_count++));
a_picture_name[$v_picture_count]=$i;
done;
for i in $(seq $v_picture_count);do
v_tmp=${a_picture_name[$i]};
v_random=$(($RANDOM%$v_picture_count+1));
a_picture_name[$i]=${a_picture_name[$v_random]};
a_picture_name[$v_random]=$v_tmp;
done;
i=1;
while [[ $i -le $v_picture_count ]];do
eog -fn $v_dir${a_picture_name[$i]}&
((i++));
if [[ $i -gt $v_picture_count ]];then
i=1;
for i in $(seq $v_picture_count);do
v_tmp=${a_picture_name[$i]};
v_random=$(($RANDOM%$v_picture_count+1));
a_picture_name[$i]=${a_picture_name[$v_random]};
a_picture_name[$v_random]=$v_tmp;
done;
fi;
sleep 3;
if [[ $(ps aux |grep -c eog) -eq 1 ]];then
exit 0;
else
v_eog=$(ps aux |grep eog |grep -v '\bgrep\b' |head -1);
v_eog=$(echo $v_eog |awk -F" " '{print $2}');
if [[ $(ps aux |grep -c eog) -gt 2 ]];then
kill $v_eog;
fi;
fi;
done;
#!/bin/bash
if [[ $# -lt 1 ]];then
echo 写入文件夹完整地址参数! 例:./prv.sh ~/Pictures/share/;
exit 0;
fi;
v_dir=$*;
if (echo $v_dir |grep -q '.*/.*');then
v_dir=$v_dir;
else
v_dir=$PWD;
fi;
if [[ ${v_dir:$((${#v_dir}-1)):1} != / ]];then
v_dir=$v_dir/;
fi;
v_picture_count=0;
for i in $(ls $v_dir);do
((v_picture_count++));
a_picture_name[$v_picture_count]=$i;
done;
for i in $(seq $v_picture_count);do
v_tmp=${a_picture_name[$i]};
v_random=$(($RANDOM%$v_picture_count+1));
a_picture_name[$i]=${a_picture_name[$v_random]};
a_picture_name[$v_random]=$v_tmp;
done;
i=1;
while [[ $i -le $v_picture_count ]];do
eog -fn $v_dir${a_picture_name[$i]}&
((i++));
if [[ $i -gt $v_picture_count ]];then
i=1;
for i in $(seq $v_picture_count);do
v_tmp=${a_picture_name[$i]};
v_random=$(($RANDOM%$v_picture_count+1));
a_picture_name[$i]=${a_picture_name[$v_random]};
a_picture_name[$v_random]=$v_tmp;
done;
fi;
sleep 3;
if [[ $(ps aux |grep -c eog) -eq 1 ]];then
exit 0;
else
v_eog=$(ps aux |grep eog |grep -v '\bgrep\b' |head -1);
v_eog=$(echo $v_eog |awk -F" " '{print $2}');
if [[ $(ps aux |grep -c eog) -gt 2 ]];then
kill $v_eog;
fi;
fi;
done;
作者: fnan 发布时间: 2011-03-03
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28