並び順

ブックマーク数

期間指定

  • から
  • まで

521 - 560 件 / 797件

新着順 人気順

shの検索結果521 - 560 件 / 797件

  • AWS 全リージョンの (ほぼ)全リソースをリストアップするシェルスクリプト - Qiita

    各リージョンの各サービスを個別に確認しなくても、全てのリソースをリストアップすることができます。 AWSアカウント解約時に、不要なアクティブリソースが残っていないかの確認にも役立つかもしれません。 AWS アカウントを解約したときに、アクティブなリソースがすべて自動的に終了されるとは限りません。アカウントを解約する前に、アクティブなリソースがあるかどうかを確認し、それらを終了することがベストプラクティスです。 for region in `aws ec2 describe-regions --query 'Regions[].RegionName' --region us-west-1 --output text` do echo "region = ${region}" aws resourcegroupstaggingapi get-resources --region ${regio

      AWS 全リージョンの (ほぼ)全リソースをリストアップするシェルスクリプト - Qiita
    • sudoコマンドでaliasを使えるようにする - Qiita

      目的 Linuxでroot権限でコマンドを実行したいとき、わざわざrootユーザに変更するのではなく、sudoコマンドを使用することが多いと思います。しかし、通常のsudoコマンドでは、あとに続くコマンドがaliasかどうかチェックされないので、設定したaliasは使用できません。なので、sudoコマンドでもaliasを使用できるようにする設定をご紹介します。 方法 sudoをsudo+半角スペースのaliasとして設定します。 そのために、自身がaliasを設定しているファイルにalias sudo='sudo 'を追加してください。または、コマンドライン上で実行してください。 このように設定することで、sudoコマンドでもaliasが使用できるようになります。 仕組み sudoのあとに半角スペースを入れることによって何が起こるかといいますと、bashのマニュアルには以下のように説明され

        sudoコマンドでaliasを使えるようにする - Qiita
      • percent symbol in Bash, what's it used for?

        Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives

          percent symbol in Bash, what's it used for?
        • Online - Reverse Shell Generator

          Online Reverse Shell generator with Local Storage functionality, URI & Base64 Encoding, MSFVenom Generator, and Raw Mode. Great for CTFs.

            Online - Reverse Shell Generator
          • GitHub - RyanGreenup/cadmus: Shell Scripts to Facilitate Effective Note Taking

            This is a self-contained shell script that uses pre-existing tools (such as TMSU and recoll) to provide an interface for markdown notes. It's command based and prints out available subcommands for any given command, these means you can use a directory of markdown files like a personal wiki, much like OneNote/Evernote/Notable, for example: and an overview of what it looks like in the terminal For e

              GitHub - RyanGreenup/cadmus: Shell Scripts to Facilitate Effective Note Taking
            • ボットネット「ShellBot」、管理不十分なLinux SSHサーバに拡散中

              AhnLabはこのほど、「ShellBot Malware Being Distributed to Linux SSH Servers - ASEC BLOG」において、管理不十分なLinux SSHサーバを標的とするサイバー攻撃のキャンペーンが展開されていると伝えた。「ShellBot」と呼ばれるボットネット型マルウェアの亜種が、管理不十分なLinux SSHサーバにインストールされるという事例が発生している。 ShellBot Malware Being Distributed to Linux SSH Servers - ASEC BLOG ShellBot(別名PerlBotとも呼ばれる)をLinux SSHサーバに配置するキャンペーンが確認されている。ShellBotは分散型サービス拒否攻撃(DDoS: Distributed Denial of Service attack)

                ボットネット「ShellBot」、管理不十分なLinux SSHサーバに拡散中
              • import - シェル用のモジュール管理

                MOONGIFTはオープンソース・ソフトウェアを紹介するブログです。2021年07月16日で更新停止しました 最近は各プログラミング言語向けにパッケージ管理が作られるようになりました。専用のファイルフォーマットで作成して、コマンドを打てばライブラリがインストールされます。使い慣れると手放せません。 今回紹介するimportはBash(だけでなく他のシェルでも)で使えるモジュールシステムです。 importの使い方 importのインストールです。 $ curl -sfLS https://import.pw > /usr/local/bin/import $ chmod +x /usr/local/bin/import 下記コマンドを実行すれば準備完了です。この内容は.bash_profileなどに記述しておけばいいでしょう。 $ . "$(command -v import)" 例えばこ

                  import - シェル用のモジュール管理
                • Check if a directory exists in Linux or Unix shell - nixCraft

                  I need to check if a directory exists or not, within a shell script running on Linux or Unix-like system? How do I check if a directory exists in a shell script? A directory is nothing but a location for storing files on the Linux system in a hierarchical format. For example, $HOME/Downloads/ would store all downloaded files or /tmp/ would store temporary files. This page shows how to see if a dir

                    Check if a directory exists in Linux or Unix shell - nixCraft
                  • macOS 10.15 Catalina でターミナルのやつが zsh になった | 林檎コンピュータ

                    デフォルトのシェルが bash から zsh というものになったそうだ。 zsh は bash の上位互換だそうで、つまり良きものなのだろう。 zsh を使ってみる Mojave から Catalina へのアップグレードした場合だと bash がまだ生き残っている。すぐには zsh にならないのだ。 ターミナルを立ち上げると次のようなメッセージが表示される。 The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`. For more details, please visit https://support.apple.com/kb/HT208050. よくわかんねーながらもchsh -s /bin/zshってのをやれって書いてある

                      macOS 10.15 Catalina でターミナルのやつが zsh になった | 林檎コンピュータ
                    • bashのhere-documentは一時ファイルを作成するらしい

                      出力はこう: this is here document 複数行に渡るテキストをリテラルとして表現したい場合に便利ですね。で、shellscriptからREST APIにリクエストを投げたくて、here-documentを使ってJSONをべたっとスクリプト内で書いてたんですけど、こんなエラーが出てました(パスはもちろん違いますよ。念のため。): /path/to/shellscript/using/here-document.sh: line 179: cannot create temp file for here-document: No space left on device 全然知らなかったけど、here-documentって一時ファイルを作成するんですね。確かめてみます。 $ docker run -it --rm centos:7 bash [root@8017e5e28d6

                        bashのhere-documentは一時ファイルを作成するらしい
                      • ディレクトリごとに環境変数を切り替えるシェルの拡張機能direnv

                        はじめに direnvはディレクトリの移動をトリガーに、環境変数を追加・削除できるシェルの拡張機能である。 ユースケースとしては以下が挙げられている。 Load 12factor apps environment variables Create per-project isolated development environments Load secrets for deployment THE TWELVE-FACTOR APPの環境変数を読み込む プロジェクトごとに開発環境を構築する デプロイするための秘密情報を読み込む インストールとシェルへのフック設定 Homebrewからインストール可能。

                          ディレクトリごとに環境変数を切り替えるシェルの拡張機能direnv
                        • CentOS7をRocky Linux8にアップグレード - Qiita

                          0x1 計画と目標 CentOS 7は停止しているため、できるだけ早くRocky Linuxに更新する必要があります。この記事では、Rocky Linuxに安全にアップグレードする方法について説明します。 更新する前に、バックアップを作成してください。 メモリが1GB未満の場合は、仮想メモリを確立する必要があります。 0x2 Rescue Kernel(Black Magic)に切り替えます cd yum -y install rsync wget wget https://raw.githubusercontent.com/johnj/centos-to8-upgrade/master/to8.sh chmod +x to8.sh ./to8.sh # エラーが発生した場合、それは問題ではありません reboot ./to8.sh # remove temp file rm -Rf /t

                            CentOS7をRocky Linux8にアップグレード - Qiita
                          • bashで変数を正規表現で置換して変数に代入する方法

                            bashで変数を置換して変数に代入する方法を紹介します。 ネットで上記の方法を調べたのですが、bashの変数を正規表現の入力にしたりとか、置換結果を変数に代入する記事があまりみつからなかったので、このエントリーでまとめておきます。 ビギナーの方向けの内容です。文字列置換ではsedを前提とします。 1.問題点 例えば、 00012345 というテキストを含むファイル「foo.txt」から「12345」を抜き出したい場合、コマンドラインで次のように実行します。 #!/bin/sh sed -e "s/[0]*\(12345\)/\1/" foo.txt 上記の内容を「foo.sh」というファイルに保存して実行すると、標準出力に「12345」を出力します。 % ./foo.sh 12345 ですが、以下のことが分かりません。 テキストファイルではなく、bashの変数を入力にしたい 置換後の内容を

                              bashで変数を正規表現で置換して変数に代入する方法
                            • The ABS programing language

                              GitHub (opens new window) A familiar syntax ABS should look familiar to most of us, as its elements are borrowed from popular programming languages such as Ruby, Python or JavaScript: obj = {} for n in 1..10 { if n % 2 == 0 { obj[n.str()] = rand(6**2) } } echo("We have %s", obj) # We have {"10": 79, ...} Scripting made easy System commands are deeply integrated (and encouraged); they make ABS idea

                              • catalinaでterminalがzshになったのを一旦bashに戻す方法 - Qiita

                                どれでも良いが ・ターミナル -> 環境設定 -> 一般 -> 開くシェルで/bin/bash ・chsh -s /bin/bash ・システム環境設定 -> ユーザとグループ -> ユーザを右クリックで詳細オプション -> ログインシェルを/bin/bash 戻すときは/bin/bashを/bin/zshにすれば上手くいく(はず)

                                  catalinaでterminalがzshになったのを一旦bashに戻す方法 - Qiita
                                • bashで過去のコマンドを検索する方法3つ - Qiita

                                  Motivation gitとかdockerとかkubectlとか、引数やオプションがてんこ盛りのコマンドを使っていると、過去に実行したコマンドを検索して参照したくなる。 最も簡単な方法:reverse-i-search ターミナルでC-rをタイプすると、過去のコマンドをインクリメンタル検索できる。検索は部分一致。C-rをタイプするたびに別な候補が表示される。このようにして順に表示した候補は、C-sで逆順に表示できる。ただし、C-sはスクリーンロックという機能にバインドされていることが多い(ターミナルが反応しなくなったように見えて焦る。C-qで解除できる)。以下のコマンドを実行してこの機能のバインドを解除しておく。

                                    bashで過去のコマンドを検索する方法3つ - Qiita
                                  • スクリプトが在るディレクトリのフルパスや名前を取得

                                    スクリプトの置かれているディレクトリのフルパスや名前を取得する方法。 スクリプトが在るディレクトリ以外から実行しても、正しく取得します。 カレントディレクトリのフルパス取得 実行場所に関係なく、スクリプトが置かれているディレクトリのフルパス取得は以下のようになります。 例 /work/test/dir/current.sh #!/bin/bash CURRENT=$(cd $(dirname $0);pwd) echo $CURRENT このスクリプトを実行すると、以下のようになります。 $ ./current.sh /work/test/dir スクリプトがあるディレクトリ以外から実行しても、同じ結果になります。 $ cd / $ /work/test/dir/current.sh /work/test/dir ただし、スクリプト内でcdコマンドを使って移動すると、移動先ディレクトリのパ

                                    • Supercharge your Kubernetes setup with OhMyZSH 🚀🚀🚀 + awesome command line tools | Prasad's Pen

                                      Almost all of my colleagues who have worked with kubernetes have had similar complaints about the kubectl tool. It's so verbose! I need to remember such long commands! This lead me to search and discover a bunch of powerful cli tools, which combined with the OhMyZSH command line framework can make your kubectl journey much smoother. How you would usually use kubectlkubectl by itself is a very powe

                                        Supercharge your Kubernetes setup with OhMyZSH 🚀🚀🚀 + awesome command line tools | Prasad's Pen
                                      • vimで`git add`する前に`--dry-run`して確認する

                                        def GitAdd(args: string) const current_dir = getcwd() try chdir(expand('%:p:h')) echoh MoreMsg echo 'git add --dry-run ' .. args const list = system('git add --dry-run ' .. args) if !!v:shell_error echoh ErrorMsg echo list return endif if !list echo 'none.' return endif for item in split(list, '\n') execute 'echoh' (item =~# '^remove' ? 'DiffDelete' : 'DiffAdd') echo item endfor echoh Question if

                                          vimで`git add`する前に`--dry-run`して確認する
                                        • gitで特定のファイルの更新を禁止する - Qiita

                                          プロジェクトによっては、そう安々と変更してほしくないファイルが有ったりします。 そこで、特定のファイルの変更をコミット出来なくするGitフックの紹介です。 例えば、.htaccessとlibディレクトリ配下の全てのファイルの変更を禁止するには以下の様なpre-commitフックを作成します。 .git/hooks/pre-commit #!/bin/sh unchangeable_files=( ^\\.htaccess$ ^lib/.* ) containsElement () { local e for e in "${@:2}"; do [[ "$1" =~ $e ]] && return 0; done return 1 } for FILE in `git diff --cached --name-status $against -- | cut -c3-`; do if con

                                            gitで特定のファイルの更新を禁止する - Qiita
                                          • [2019年5月] git for windows の bash で SDKMAN! 入れようとしたら zip がないって怒られた。 - Qiita

                                            $ curl -s "https://get.sdkman.io" | bash -+syyyyyyys: `/yho:` -yd. `/yh/` +m. .oho. hy .` .sh/` :N` `-/o` `+dyyo:. .yh:` `M- `-/osysoym :hs` `-+sys: hhyssssssssy+ .sh:` `N: ms/-`` yy.yh- -hy. `.N-````````+N. `od/` `N- -/oM- ddd+` `sd: hNNm -N: :do` .M. dMMM- `ms. /d+` `NMMs `do .yy- :N` ```mMMM. - -hy. /MMM: yh `+d+` `:/oo/` `-/osyh/ossssssdNMM` .sh: yMMN` /m. -dh- :ymNMMMMy `-/shmNm-`:N/-.`` `.sN

                                              [2019年5月] git for windows の bash で SDKMAN! 入れようとしたら zip がないって怒られた。 - Qiita
                                            • Bashプロンプトとコマンド履歴をちょっとだけ見やすくする | DevelopersIO

                                              はじめに こんにちは、AWS事業本部のニシヤマです。はいマスキュラー。 サーバを立ち上げた際にデフォルトのシェルがBashであることが多々あると思います。備忘録も兼ねてBashの時に私が実施している設定をご紹介します。 ちょっと困ること 私がデフォルトのBashの状態だと困ることとして以下のようなことがあります。 改行があるコマンドなどを実行した際にぱっと見でプロンプトとコマンドが区別しづらい 調査などでコマンド履歴を見た時にいつ実行されたコマンドなのか判別ができない やりたいこと プロンプトが区別しやすいように色を付ける コマンド履歴にタイムスタンプを付ける 結論 Linuxの場合、以下のコマンドを実行します。 $ cat << EOS >> ~/.bashrc HISTFILESIZE=10000 HISTTIMEFORMAT='%Y/%m/%d %H:%M:%S ' PS1='\[\

                                                Bashプロンプトとコマンド履歴をちょっとだけ見やすくする | DevelopersIO
                                              • GitHub - screetsec/Sudomy: Sudomy is a subdomain enumeration tool to collect subdomains and analyzing domains performing automated reconnaissance (recon) for bug hunting / pentesting

                                                You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                  GitHub - screetsec/Sudomy: Sudomy is a subdomain enumeration tool to collect subdomains and analyzing domains performing automated reconnaissance (recon) for bug hunting / pentesting
                                                • Automake error './ltmain.sh' not found

                                                  I've installed mingw and msys by using mingw-get-setup.exe. I've also installed Autotools(autoconf, automake,m4,libtool) into C:\/opt/autotools. When I run automake, the following error always occurs: configure.ac:11: error: required file './ltmain.sh' not found If I copy ltmain.sh from libtool’s installed tree, execution will finish normally. How can I configuure automake to find ltmain.sh withou

                                                    Automake error './ltmain.sh' not found
                                                  • How to Monitor the Progress of Linux Commands (With pv and progress)

                                                    Instead of flying blind, use the Linux pv and progress commands to track a command's progress. These utilities will give you progress bars for commands that don't normally have any. You'll see an estimated time until completion, too. Starting a command from the terminal window can sometimes feel like a long-haul flight without a video screen. You have nothing to give any indication if all is well

                                                      How to Monitor the Progress of Linux Commands (With pv and progress)
                                                    • Github actionでvenv環境をキャッシュする - Atsuo Ishimoto's blog

                                                      Github actionでvenv環境をキャッシュする¶これまで、PythonのプロジェクトでGithub Actionを使うとき、こんな感じで仮想環境ごとキャッシュしていました。 # 仮想環境を作成 - name: Create venv run: | python3 -m venv .venv # 仮想環境をキャッシュから復元 - name: Cache venv dependencies uses: actions/cache@v1 with: path: .venv key: venv-${{ runner.os }}-${{ hashFiles('requirements.txt') }} restore-keys: | ${{ runner.os }}-venv-

                                                        Github actionでvenv環境をキャッシュする - Atsuo Ishimoto's blog
                                                      • set -e, -u, -o, -x pipefail explanation

                                                        bash_strict_mode.md Table of Contents set -e, -u, -x, -o pipefail set -e set -x set -u set -o pipefail Setting IFS Original Reference set -e, -u, -x, -o pipefail The set lines These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing. With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you ca

                                                          set -e, -u, -o, -x pipefail explanation
                                                        • GitHub - shellgei/shellgei160: 書籍: シェル・ワンライナー160本ノックの情報ページ #shellgei160

                                                          You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                            GitHub - shellgei/shellgei160: 書籍: シェル・ワンライナー160本ノックの情報ページ #shellgei160
                                                          • shellmagic.xyz - このウェブサイトは販売用です! - shellmagic リソースおよび情報

                                                            This webpage was generated by the domain owner using Sedo Domain Parking. Disclaimer: Sedo maintains no relationship with third party advertisers. Reference to any specific service or trade mark is not controlled by Sedo nor does it constitute or imply its association, endorsement or recommendation.

                                                              shellmagic.xyz - このウェブサイトは販売用です! - shellmagic リソースおよび情報
                                                            • 🔮

                                                              🔮 自己紹介 Name : azu 🐦 Twitter : @azu_re 📝 Blog: Web scratch, JSer.info 📚 Book: JavaScript Primer 🏗️ Develop: textlint, secretlint, HonKit OrbStack OrbStack · Fast, light, simple Docker & Linux on macOS Drop in replace Docker for mac 早い、ファンを回さない、便利 GUIがまとも OrbStackの特徴 Portを開けなくてもContainerに直接アクセスできる Container側portをexposeしなくても、macOS側からアクセスできる node --inspectorのようなデバッガーを外から接続するのに便利 macOS側にOrbStackのC

                                                              • Shell Scripts Are Executable Documentation

                                                                Becoming Shell Literate Lets You Share Knowledge Comment from mooreds: One thing the author didn't cover is how you can share reified knowledge when you write shell scripts... That is really really powerful, because you can not only share it with others but also with your future self. Summary: Instead of writing docs with shell commands, I invert that and write shell scripts with comments. I show

                                                                • 空白を含むパス名を含むコマンド文字列をシェル(bash)で処理する - それマグで!

                                                                  " program files " のような空白を含むパス名を持ったコマンド全体を、変数に保持しててそれを実行したい時 そのままだと動かない。 ## これが実行できない。 cmd='ls ~/Library/Application\ Support/' $cmd 空白を含むパス名を入れたコマンドを文字列として、それを実行しようとするとエスケープの処理で頭を悩ますことになる。 eval を使う cmd='ls ~/Library/Application\ Support/' eval $cmd または、sh 経由にする cmd='ls ~/Library/Application\ Support/' sh -c "$cmd": 参考資料 https://stackoverflow.com/questions/836334/executing-commands-containing-space

                                                                    空白を含むパス名を含むコマンド文字列をシェル(bash)で処理する - それマグで!
                                                                  • ファイルの変更を検知して特定のコマンドを実行する bash スクリプトを書いてみた

                                                                    社会人大学院の課題で独自の bash スクリプトを提出するものがあり、その時書いたたものがわりと便利そうだったので公開します。 どんな bash スクリプト? 特定のファイル群の変更を検知して、特定のコマンドを実行する bash スクリプトです。 ビルドやテストフレームワークにあるwatchオプションを、任意のコマンド、任意のファイル群で実行できるイメージです。 -cで実行するコマンド、-fで監視対象のファイル群を指定します。 $ ./watch-files.sh -c 'echo "update"' -f './src/**/*.py' watched ./src/**/*.py ... If want to terminate, press to Ctrl-D update # -cで指定した条件に合致するファイルを変更した際に-cで指定したコマンドが実行される update # Ct

                                                                      ファイルの変更を検知して特定のコマンドを実行する bash スクリプトを書いてみた
                                                                    • dotfiles/op.sh at feee2d2a3c2e10ef89863ff27634ddbec1b27d5b · Hacksore/dotfiles

                                                                      A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

                                                                        dotfiles/op.sh at feee2d2a3c2e10ef89863ff27634ddbec1b27d5b · Hacksore/dotfiles
                                                                      • Release 5.0.0 · google/zx

                                                                        You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                                          Release 5.0.0 · google/zx
                                                                        • import

                                                                          import is a simple and fast module system for Bash and other Unix shells. Inspired by Go's import command, you specify the URL of the shell script, and the import function downloads the file and caches it locally, forever. The code will never change from below your feet, and will continue to work offline. 👋 Examplehttps://git.io/fAWiz ← This URL contains a simple add shell function: add() { expr

                                                                            import
                                                                          • なぜ次期macOSはzshを標準シェルに選んだのか|unknown protocol

                                                                            ニュースとしては小ネタだが、割と最近にzshからbashに戻した組としては、およよと思った。Apple自身は、このように発表している。 https://support.apple.com/en-ca/HT208050 Starting with the macOS Catalina beta, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.「Catalinaのベータ版でzshをデフォルトにした。ちなみに今のバージョンだってzshをデフォルトにできるんだけどな」と書かれている。 That actually isn't very surprising since Bash o

                                                                              なぜ次期macOSはzshを標準シェルに選んだのか|unknown protocol
                                                                            • シェルスクリプトサンプルコードでよく見かける typeset や declare ってなに? | ゲンゾウ用ポストイット

                                                                              後日投稿したエントリで、サンプルコードとともに検証をしてみました。 興味があればそちらも御覧ください。 Bash のビルトインコマンド "declare" の使い方紹介(その1)Bash のビルトインコマンド "declare" の使い方紹介(その2:大文字小文字の自動変換 )古いシェルスクリプトコードでは、以下のような命令で変数を定義する方法が取られていることが多いです。 # 定義 $ VAR1=123 # 出力 $ echo "$VAR1" 123一方、Github で公開されているシェルスクリプトを見ていると、 typeset や declare を使って変数を定義している例をよく見かけます。 それぞれの違いと使い方について調べてみました。 変数定義の方法は3つ改めて Bash の変数定義方法を列挙してみます。 Bash では 定義なしに変数を生成 することができるが、 明示的に定義

                                                                                シェルスクリプトサンプルコードでよく見かける typeset や declare ってなに? | ゲンゾウ用ポストイット
                                                                              • printenv、env、set、exportコマンドの違いに関して

                                                                                作成日:2020/01/29 CentOS / Redhat Enterprise Linux における変数関連のコマンドを紹介します。 (*)bash を想定しています。他のシェルでは動作が異なる可能性が高いので注意してください。 参考:シェル変数と環境変数の違い シェル変数:シェル内のみ有効 環境変数:子シェル、シェルから実行したプログラムにも引き継がれる変数。 (注意)分かりやすく簡単に記載しており、一部の環境や分野では記載内容が異なる可能性があります。あくまでも参考程度でお読みください。 比較表 比較は以下の表の通りとなります。

                                                                                • bashのforループのin句は省略できる - 備忘録置いとく

                                                                                  bashで配列内にある要素が存在しているか確認するための関数を書こうと思って,stackexchangeとかにあるかなと思って見てみたところ,見慣れないforの使い方があったのでメモする. containsElement () { local e match="$1" shift for e; do [[ "$e" == "$match" ]] && return 0; done return 1 } $ array=("something to search for" "a string" "test2000") $ containsElement "a string" "${array[@]}" $ echo $? 0 $ containsElement "blaha" "${array[@]}" $ echo $? 1 出典元: Check if a Bash array conta