5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

定義した関数を export -f (Bash)

Last updated at Posted at 2021-03-04

こんにちは。
bash では定義した関数を export -f できます(POSIX ではこの機能を持っていません)。定義した関数を xarg で使う場合には必要となります(下記例)1

export_f_myfunc.sh
# !/bin/bash
myfunc() { myfunc0 "$1"; }
myfunc0() { echo "$1"; }
export -f myfunc myfunc0

find . -type f | xargs -I% bash -c "myfunc %"
  1. 参考記事:「xargsにbashのfunctionを渡す方法

5
1
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
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?