sh -x somefile.sh
在somefile.sh 文件里加上set+x set-x
gzip -t
if [[ 0 == $? ]]; thenecho "good zip"
elseecho "bad zip"
fi
可以简化为:
gzip -t && echo "good zip" || echo "bad zip"
if [[ -s $file ]]; thenecho "not empty"
fi
stat -c %s $file
stat --printf='%sn' $file
wc -c $file
${string//pattern/replacement}
a='a,b,c'
echo ${a//,/ /}
string="My string"
if [[ $string == *My* ]]; thenecho "It's there!"
fi
rsync -r -t -v /source_folder /destination_folder
rsync -r -t -v /source_folder [user@host:/destination_folder
为所有txt文件加上.bak 后缀:
rename '.txt' '.txt.bak' *.txt
去掉所有的bak后缀:
rename '*.bak' '' *.bak
把所有的空格改成下划线:
find path -type f -exec rename 's/ /_/g' {} ;
把文件名都改成大写:
find path -type f -exec rename 'y/a-z/A-Z/' {} ;
for ((i=0; i < 10; i++)); do echo $i; done
for line in $(); do echo $line; done
for f in *.txt; do echo $f; done
while read line ; do echo $line; done < a.txt
| while read line; do echo $line; done
| sed -e '/^$/d'
(echo "abc"; echo ""; echo "ddd";) | awk '{if (0 != NF) print $0;}'
[[ - ]]
本文发布于:2024-02-02 12:23:43,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170684782343775.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |