嗨,有人可以帮我解决这个问题。
如何编写一个脚本作为参数接收文件名并以这种方式显示其修改日期和时间:
[user@localhost...]$ bash script.sh temp.txt
the file temp.txt was modified on May 1 20:20
然后修改该脚本,使其以这种方式列出名称包含给定模式的目录的修改日期:
[user@local....]$ bash script.sh testRegex Pub
the file testRegex was modified on May 1 20:22
the directory /home/user/Public was modified on Dec 26 08:00
the directory /home/user/Pubs. was modified on May 2 20:00
请帮助我快速回答
由于
答案 0 :(得分:3)
实际上这很简单。你应该阅读stat命令,因为@John Bollinger说。我还使用date命令格式化日期。您可以阅读有关脚本here
的参数将所有这些结合起来会给出 -
<div class="threesixty headphone">
<div class="headphones spinner">
<span>0%</span>
</div>
<ol class="headphones threesixty_images"></ol>
</div>
<p class="threesixtybtns">
<a class="btn btn-inverse headphones custom_prev"><i class="icon-prev"></i></a>
<a class="btn btn-inverse headphones custom_play"><i class="icon-play"></i></a>
<a class="btn btn-inverse headphones custom_next"><i class="icon-next"></i></a>
</p>
<script>
jQuery(document).ready(function() {
var headphone = jQuery('.headphone').ThreeSixty({
totalFrames: 31, // Total no. of image you have for 360 slider
endFrame: 31, // end frame for the auto spin animation
currentFrame: 1, // This the start frame for auto spin
imgList: '.headphones.threesixty_images', // selector for image list
progress: '.headphones.spinner', // selector to show the loading progress
imagePath: '/wp-content/themes/Divi-child/headphone/', // path of the image assets
filePrefix: 'Headphones_360_AE_png_', // file prefix if any
ext: '.png', // extention for the assets
height: 1000,
width: 1000,
navigation: false,
responsive: true
});
jQuery('.headphones.custom_prev').bind('click', function(e) {
headphone.previous();
});
jQuery('.headphones.custom_next').bind('click', function(e) {
headphone.next();
});
jQuery('.headphones.custom_play').toggle(function(e) {
headphone.play();
}, function() {
headphone.stop();
});
jQuery('.headphones.custom_stop').bind('click', function(e) {
headphone.stop();
});
});
</script>
<div class="threesixty helmet" style="display: none;">
<div class="helmets spinner">
<span>0%</span>
</div>
<ol class="helmets threesixty_images"></ol>
</div>
<p class="threesixtybtns" style="display: none;">
<a class="btn btn-inverse helmets custom_prev"><i class="icon-prev"></i></a>
<a class="btn btn-inverse helmets custom_play"><i class="icon-play"></i></a>
<a class="btn btn-inverse helmets custom_next"><i class="icon-next"></i></a>
</p>
<script>
jQuery(document).ready(function() {
var helmet = jQuery('.helmet').ThreeSixty({
totalFrames: 31, // Total no. of image you have for 360 slider
endFrame: 31, // end frame for the auto spin animation
currentFrame: 1, // This the start frame for auto spin
imgList: '.helmets.threesixty_images', // selector for image list
progress: '.helmets.spinner', // selector to show the loading progress
imagePath: '/wp-content/themes/Divi-child/helmet/', // path of the image assets
filePrefix: 'Helmets_360_AE_png_', // file prefix if any
ext: '.png', // extention for the assets
height: 1000,
width: 1000,
navigation: false,
responsive: true
});
jQuery('.helmets.custom_prev').bind('click', function(e) {
helmet.previous();
});
jQuery('.helmets.custom_next').bind('click', function(e) {
helmet.next();
});
jQuery('.helmets.custom_play').toggle(function(e) {
helmet.play();
}, function() {
helmet.stop();
});
jQuery('.helmets.custom_stop').bind('click', function(e) {
helmet.stop();
});
});
</script>
答案 1 :(得分:1)
执行此操作的好方法是传递选项和值:
例如:
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Button> e)
{
base.OnElementChanged(e);
if (Control != null) {
Control.SetBackgroundResource(Resource.Drawable.layout_bg);
}
}
像这样调用脚本:
file_name=""
help_message="To use this script type script.sh --file /path/to/file.txt"
# -- Get input options (if any)
while [[ $# > 0 ]] ;do
key="$1"
case ${key,,} in
-f|--file)
file_name="${2,,}"
shift
;;
-h|--help)
echo -e "$help_message"
exit;
shift
;;
esac
shift
done
关于脚本的“逻辑”,你必须弄明白; - )