Giter VIP home page Giter VIP logo

mastering-linux-shell-scripting-2e-ja's Introduction

マスタリングLinuxシェルスクリプト 第2版


表紙


本リポジトリはオライリー・ジャパン発行書籍『マスタリングLinuxシェルスクリプト 第2版』のサポートサイトです。

サンプルコード

ファイル構成

フォルダ名 説明
appA 付録Aで使用するソースコード
ch01 1章で使用するソースコード
ch02 2章で使用するソースコード
... ...
ch14 14章で使用するソースコード

サンプルコードの解説は本書籍をご覧ください。

ライセンス

MIT

正誤表

下記の誤りがありました。お詫びして訂正いたします。

本ページに掲載されていない誤植など間違いを見つけた方は、[email protected]までお知らせください。

第1刷

■7章 7.2.1 配列の引き渡し P.146

#!/bin/bash
myfunc() {
    arr=$@
    echo "The array from inside the function: ${arr[*]}"
}

test_arr=(1 2 3)
echo "The original array is: ${test_arr[*]}"
myfunc ${test_arr[*]}

#!/bin/bash
myfunc() {
    arr=("$@")
    echo "The array from inside the function: ${arr[*]}"
}

test_arr=(1 2 3)
echo "The original array is: ${test_arr[*]}"
myfunc "${test_arr[@]}"

■7章 7.2.1 配列の引き渡し P.147

関数の中で配列を取得するために$@が使われていることに注意してください。これを$1にすると、最初の配列要素だけが返されます。
#!/bin/bash
myfunc() {
    arr=$1
    echo "The array from inside the function: ${arr[*]}"
}

my_arr=(5 10 15)
echo "The original array: ${my_arr[*]}"
myfunc ${my_arr[*]}

関数内で引数を配列として扱うために("$@")が使われていることと、関数の引数を指定する際に"${test_arr[@]}"のように[@]を使用したうえで二重引用符で囲むことに注意してください。("$@")を("$1")にすると、最初の配列要素だけが返されます。
#!/bin/bash
myfunc() {
    arr=("$1")
    echo "The array from inside the function: ${arr[*]}"
}

my_arr=(5 10 15)
echo "The original array: ${my_arr[*]}"
myfunc "${my_arr[@]}"

■7章 7.8 練習問題 7-1 P.155

#!/bin/bash
myfunc() {
    arr=$1
    echo "The array: ${arr[*]}"
}

my_arr=(1 2 3)
myfunc ${my_arr[*]}

#!/bin/bash
myfunc() {
    arr=("$1")
    echo "The array: ${arr[*]}"
}

my_arr=(1 2 3)
myfunc "${my_arr[@]}"

■7章 7.8 練習問題 7-4 P.155

#!/bin/bash
myfunc() {
    arr=$@
    echo "The array from inside the function: ${arr[*]}"
}

test_arr=(1 2 3)
echo "The origianl array is: ${test_arr[*]}"
myfunc (${test_arr[*]})

#!/bin/bash
myfunc() {
    arr=("$@")
    echo "The array from inside the function: ${arr[*]}"
}

test_arr=(1 2 3)
echo "The origianl array is: ${test_arr[*]}"
myfunc ("${test_arr[@]}")

■7章 付録B 練習問題の解答 7-1 P.357

#!/bin/bash
myfunc() {
    arr=$1
    echo "The array: ${arr[*]}"
}

my_arr=(1 2 3)
myfunc ${my_arr[*]}

#!/bin/bash
myfunc() {
    arr=("$1")
    echo "The array: ${arr[*]}"
}

my_arr=(1 2 3)
myfunc "${my_arr[@]}"

■7章 付録B 練習問題の解答 7-4 P.358

#!/bin/bash
myfunc() {
    arr=$@
    echo "The array from inside the function: ${arr[*]}"
}

test_arr=(1 2 3)
echo "The origianl array is: ${test_arr[*]}"
myfunc (${test_arr[*]})

#!/bin/bash
myfunc() {
    arr=("$@")
    echo "The array from inside the function: ${arr[*]}"
}

test_arr=(1 2 3)
echo "The origianl array is: ${test_arr[*]}"
myfunc ("${test_arr[@]}")

#!/bin/bash
myfunc() {
    arr=$@
    echo "The array from inside the function: ${arr[*]}"
}

test_arr=(1 2 3)
echo "The origianl array is: ${test_arr[*]}"
myfunc ${test_arr[*]}

#!/bin/bash
myfunc() {
    arr=("$@")
    echo "The array from inside the function: ${arr[*]}"
}

test_arr=(1 2 3)
echo "The origianl array is: ${test_arr[*]}"
myfunc "${test_arr[@]}"

mastering-linux-shell-scripting-2e-ja's People

Contributors

miyagawa-orj avatar nmantani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.