前書き
このリポジトリは、catコマンドを実行してファイルから文字列を取得し、空白が2回続く文字列を正しく出力するプログラムを実行します
インストールする必要のあるコマンド
- git
クイックスタート
上記のコマンドをインストール済みの方は、以下のコマンドを実行してリポジトリからダウンロード後、ディレクトリを移動し、シェルスクリプトを実行してcatコマンドで取得した文字列の空白がどうなるか確認してみてください
ubuntu
出力結果
/hello/cat/command/hello world/test string.png
/hello/cat/command/hello world/test string.png
macos
MacPorts
出力結果
/hello/cat/command/hello world/test string.png
/hello/cat/command/hello world/test string.png
windows
WSL2
出力結果
/hello/cat/command/hello world/test string.png
/hello/cat/command/hello world/test string.png
MSYS2 MINGW64
出力結果
/hello/cat/command/hello world/test string.png
/hello/cat/command/hello world/test string.png
実行手順
ubuntu
クリックして詳細を開く
事前確認
以下のコマンドを端末に打ち込んでcommand not foundが出なければokです
preinstall
端末にcommand not foundが出たコマンドを以下のコマンドでインストールしてください
コマンド
以下のコマンドを端末で実行することで詳細のような文字列が出力されるはずです
詳細
/hello/cat/command/hello world/test string.png
/hello/cat/command/hello world/test string.png
macos
クリックして詳細を開く
事前確認
以下のコマンドをターミナルに打ち込んでcommand not foundが出なければokです
※macosはMacPortsパッケージマネージャを使用してコマンドを管理します。もしインストールしていない方は以下のリンクからMacPortsのインストール手順をご覧ください
またコマンドに別名を設定して既存の環境と競合しないでコマンドを呼び出せるようにします。
初めてこのブログを利用する方は、以下の2つの記事を参考に環境構築してください
preinstall
ターミナルでcommand not foundが出たコマンドを以下のコマンドでインストールしてエイリアスを設定してください
コマンド
以下のコマンドをターミナルで実行することで詳細のような文字列が出力されるはずです
詳細
/hello/cat/command/hello world/test string.png
/hello/cat/command/hello world/test string.png
windows
クリックして詳細を開く
事前確認
以下のコマンドをプロンプトに打ち込んでcommand not foundが出なければokです
WSL2
MSYS2 MINGW64
※windowsはWSL2とMSYS2 MINGW64で確認しています。可能な限りWSL2をインストールしていただいて、もし設定できなかった場合はMSYS2をインストールすることで実行できますが、所々WSL2でしか実行できないコマンドが出てくるかもしれません。WSL2とMSYS2のインストール方法は下記の記事を参考にしてください
preinstall
プロンプトでcommand not foundが出たコマンドを以下のコマンドでインストールしてください
WSL2
MSYS2 MINGW64
コマンド
以下のコマンドをプロンプトで実行することで詳細のような文字列が出力されるはずです
WSL2
詳細
/hello/cat/command/hello world/test string.png
/hello/cat/command/hello world/test string.png
MSYS2 MINGW64
詳細
/hello/cat/command/hello world/test string.png
/hello/cat/command/hello world/test string.png
後書き
$resultにダブルクオーテーションを付けるか付けないかで出力結果が変わります。付けた方は/hello/cat/command/hello world/test string.pngのようにtestとstringの間の空白が意図した通りに出力されています