Skip to content

Instantly share code, notes, and snippets.

@dz1984
Created August 9, 2013 07:56
Show Gist options
  • Save dz1984/6191880 to your computer and use it in GitHub Desktop.
Save dz1984/6191880 to your computer and use it in GitHub Desktop.
會抓資料夾已經產生多少Code file,再新增一個套用Template格式的空白Code file。
#!/bin/bash
# Create more PHP source file on batch processing.
usage="makePHP.sh number\n\tnumber - set up quantity files.";
#echo "Argument lenght is $#";
if [ $# -gt 1 ] || [ $# -eq 0 ]; then
# Display help message.
echo -e $usage;
else
for (( i=1; i<=$*; i=i+1 ))
do
counter=$(expr $(ls -1 t*.php | wc -l ) + 1);
late=$(ls -1 t*.php | tail -1);
next=$(printf "t%03d.php" $counter);
if [[ ${next:0:4} < ${late:0:4} ]]; then
counter=1;
next=t001.php
fi
# Made other file name when catch the same name
while [ -f $next ]; do
counter=$(expr $counter + 1);
next=$(printf "t%03d.php" $counter);
done;
# Create the tamplate file.
echo "Create file....$next";
cat < template.txt > $next;
#chmod a+x $next;
bash ./CreatePHPLinks.sh
echo "Finish.";
done;
fi
<?php
/*
Comment.
*/
$TITLE='None';
$FORMAT='HTML'; #default format is HTML
if($FORMAT=='HTML')
include_once('html_before.inc');
include_once('utility.inc');
//Main Block
if ($FORMAT=='HTML')
include_once('html_after.inc');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment