我有疑问:
练习是:
编写一个脚本来检测过去 15 天内未登录且属于“校友”组的用户。该列表将添加到 /var/log/alumnos_sin_login。
我的做法:
#2)
#!/bin/bash
#Scripts which detects users whose group is "alumnos" who have been not logged in,
#in the last 15 days. The users' list is added to /var/log/alumnos_sin_login
#RESULTADO holds those users who haven't entered in the last 15 days
#LISTA holds alumnos' users' list
#USUAEIO actual user being parsed
#RAIZ != "" if user has logged -15 days
#Read and check if group is not created
exec 0 </etc/gshadow
if [ $(grep …Run Code Online (Sandbox Code Playgroud) 我想编写一个脚本来查找所有.cpp以.cc. 搜索将从开始路线 R 递归完成,这是脚本的参数。
如果没有写入参数,R 将是实际目录。
我写过:
#!/bin/bash
R=.
if [[ $# == 1 ]]
then
echo "$# == 1"
if [[ -d $1 ]]
echo "$1 is directory"
then
R=$1
else
printf "Error $1 should be a directory"
exit 1
fi
find $R -name "*.cpp" -exec sh -c 'mv {} $(dirname {})${$(basename {})%.cpp}".cc" ' \;
exit 0
else
printf "Invocation is: $0 directory"
exit 1
fi
Run Code Online (Sandbox Code Playgroud)
但是我知道我在 find 行中遇到了麻烦,因为我不知道如何表达我想在使用 {} 时删除扩展名并附加新的扩展名