Last active
January 21, 2016 06:47
-
-
Save psychoss/4fbbfcfc584b9a7a4829 to your computer and use it in GitHub Desktop.
Shell Scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DATE=`date +%Y-%m-%d` | |
for file in ./* | |
do | |
if [ -d "$file" ] | |
then | |
echo $file-$DATE.zip | |
#7z a -r $file-$DATE.zip $file | |
# else | |
# if [ ${file: -4} == ".txt" ] # this is the snag | |
# #then | |
# # do something txt-ish | |
# fi | |
fi | |
done; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 一段脚本,给匹配的文件加上时间戳 | |
# 修改这段代码,替换或者添加文件扩展明^.*(7z|zip)$ | |
# 获取系统时间 | |
shorttime=`date +%Y-%m-%d--%H:%M:%S` | |
# 遍历当前文件夹 | |
for i in *.* | |
do | |
# 忽略已修改的文件,并通过扩展名筛选待添加文件 | |
if [[ ! "${i}" =~ [0-9]{4}-[0-9]{2}-[0-9]{2} ]] && [[ "${i}" =~ ^.*(7z|zip)$ ]];then | |
ext=${i##*.} | |
mv $i ${i%.*}$(date "+-%Y-%m-%d.${ext}") | |
fi | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATE=`date +%Y-%m-%d` & echo $DATE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
original_string='i love Suzi and Marry' | |
string_to_replace_Suzi_with=Sara | |
result_string="${original_string/Suzi/$string_to_replace_Suzi_with}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# delete all files that match a pattern | |
find . -name '*.css' -delete | |
find . -name '*.js' -delete | |
find . -name 'saved_resource*' -delete | |
find . -name '510f1a6865' -delete | |
find . -name 'css' -delete | |
#-type d restricts to directories | |
#-empty restricts to empty ones | |
#-delete removes each directory | |
find . -type d -empty -delete | |
# find -regextype posix-extended -regex '.*[[:digit:]]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment