bashでは記号類をたくさん使うので、この書き方は何?と思っても検索でなかなか出てこないことがあると思う。 そこで知っていると便利なコマンドを残しておく。 随時追記予定。 確認に使用したbashのバージョンは以下のとおり。
LinuxやUNIXを使う上で、ある程度使えると非常に便利な置換コマンドが、このsedコマンドだ。 今回は、このsedコマンドで覚えておきたい使い方について紹介する。 なお、今回の置換・編集の例として、以下のファイルを用いて説明する。 [root@test-centos7 work]# cat /root/sed_test.conf # line 1 line1=enable # line 2 line2=disable # line 3 line3=enable # line 4 line4=enable 1.基本的な使い方 sedコマンドの基本的な使い方としては、以下のようにコマンドを実行することでファイル・標準出力の内容で文字列の置換を行う事だ。 なお、条件の最後に「g」を付けないと、"最初に、マッチした箇所のみ"置換するので注意。 ファイルの内容を置換する場合 sed 's/置換前
こんにちは。 マネーフォワードでアグリゲーション開発を担当しています中川です。 今回のブログは、私が bash スクリプトを書く際に心がけている事のおさらいをします。 知ってて当たり前のことかも知れませんが、意外と理解されていないアレです。 では、私が bash スクリプトを書く際によく使う記述を一つずつ紹介します。 2種類の shebang シェルスクリプトの一行目に必ず記述する #! で始まる行を shebang と言います。 bash スクリプトの shebang は、bash を絶対パスで指定する方法と、env を使って指定する方法の二種類あります。 bash を絶対パスを指定する方法 #!/bin/bash env を使ってを指定する方法 #!/usr/bin/env bash 前者は /bin/bash が使われます。 (/bin/bash が存在しなければスクリプトの起動時に
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く