タグ

関連タグで絞り込む (0)

  • 関連タグはありません

タグの絞り込みを解除

bashとprogrammingとshellに関するLayzieのブックマーク (6)

  • シェルスクリプトのデバッグは typeset または declare を使うと良いかも - よんちゅBlog

    はじめに つい最近知った便利なデバッグ方法 (長年シェルスクリプトを書いているのに知らなかった。これが常識だったら恥ずかしい…) シェルスクリプトのデバッグでは echo で変数の中身を見るという原始的な方法をよく使うかと思います。 いわゆる プリントデバッグ というやつですね。 もう少し詳しいデバッグが必要な場合は、 set -x と set +x でデバッグしたい部分を囲むという方法もあります。 今回は プリントデバッグ で使う echo の代わりに typeset or declare を使うと良いというお話です。 プリントデバッグは typeset or declare を使おう typeset or declare は変数宣言などでよく使うコマンドですが、変数の中身を見るのにも使えます。 echo と比べて何が良いのかというと、変数の中身はもちろん変数名や変数の型も表示してくれ、

    シェルスクリプトのデバッグは typeset または declare を使うと良いかも - よんちゅBlog
  • Bash Brace Expansion Tutorial: 6 Examples of Expanding Expressions within Braces

    Bash Brace Expansion Tutorial: 6 Examples of Expanding Expressions within Braces Bash Shell expansion One of the operation of the shell when it analyzes the input is Shell expansion. Bash provides different types of expansion. In this article let us review an important expansion — “Brace expansion”. This article is part of our on-going Bash Tutorial series. Brace expansion is used to generate arbi

  • Bash Shell Exit Status Tutorial with Practical Examples

    $? Shell Variable The shell variable name $? is a special built-in variable which has the exit status of the last command executed. After the shell function execution, $? returns the exit status of the last command executed in a function. After the shell script execution, $? returns the exit status of the last command executed in the script. Sample Shell Script that Explains Shell-Command Exit Sta

  • Bash Scripting Introduction Tutorial with 5 Practical Examples

    Bash Scripting Introduction Tutorial with 5 Practical Examples Similar to our on-going Unix Sed and Unix Awk series, we will be posting several articles on Bash scripting, which will cover all the bash scripting techniques with practical examples. Shell is a program, which interprets user commands. The commands are either directly entered by the user or read from a file called the shell script. Sh

  • bash

    Linux においての「コマンド」とは、シェルによって実行ファイルが実行されていることを意味します。 たとえば ls コマンドをユーザが入力した際、その入力はシェルにとっての入力でしかありません。シェルはユーザから入力された ls という文字列を「ls という実行ファイルを実行する」と解釈し、カーネルに伝えます。 ls という実行ファイルを実行した結果がシェルによってユーザに伝えられ、あたかもユーザは ls という実行ファイルを直接実行したように感じることができます。 このように「実行したように」というのがユーザインタフェースとしてのシェルの役目です。 しかし、今回はスクリプト言語としての bash をメインに扱うので、この章は軽く流していただいて結構です。 ご存じのように bash はプログラミング言語(シェルスクリプト)のひとつとして動作します。 プログラミング言語として、最低限備わっ

  • bashで始めるシェルスクリプト基礎の基礎(1/2)

    GUIに対するCUIの優位性の1つとして、作業の自動化が挙げられる。普段行う作業を1つのコマンドにまとめたり、複数のファイルに対して同じ処理を繰り返し行ったりといったことが比較的簡単なのだ。WindowsにもWSH(Windows Script Host)が用意されている。しかし、Linuxのbashスクリプトの方が簡単なのだ。 シェルスクリプトの基はコマンドを並べること コマンドによる作業を自動化するには、その内容を記述したテキストファイルを用意すればいいのです。このテキストファイルを「シェルスクリプト」といいます。 最も簡単な自動化 最も簡単なシェルスクリプトは、コマンドをそのまま並べることです。例えば、tarコマンドでファイルのバックアップを取るとしましょう。単純にルートディレクトリから下を全部バックアップするにしても、/devや/tmpは必要ないですね。すると、

    bashで始めるシェルスクリプト基礎の基礎(1/2)
  • 1