[jq] endswith で文字列が特定の文字列で終わるか確認する

作成日: 2026年09月19日

endswith を使うと、文字列が指定した文字列で終わるか確認できます。下記の例では、report.csv.csv で終わるか確認しています。

echo '"report.csv"' | jq 'endswith(".csv")'

実行結果は下記のとおりです。

true

endswith(".csv") は、入力された文字列の末尾が .csv と一致する場合に true を返します。

jq