LoginSignup
0
0

More than 5 years have passed since last update.

crontabに命令文を追加するスクリプト

Posted at

grepとsedで重複なく、crontabに命令文を追加する

function edit_file () {
    local keyword=$1
    local statement='$a\'"$2"
    local file_path=$3

    local set_flag=`grep "$keyword" "$file_path" | wc -l`

    if [ $set_flag -eq 0 ]; then
        sed -i "$statement" "$file_path"
    fi
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0