ユーザ用ツール

サイト用ツール


bash

ちなみにWindows版

http://win-bash.sourceforge.net/ から shell.w32-ix86.zip をダウンロード。

基本

CSVファイル読込

#!/bin/sh
while read A B C
do
  echo $A;
  echo $B;
  echo $C;
done < hoge.csv 

条件判定(testコマンド)

 コマンド引数の真偽を判断する
     「 test コマンド引数 」と「 test (コマンド引数) 」は等しい
     「 test コマンド引数 」と「 test !コマンド引数 」は真偽が逆になる
 [ ]コマンドがエイリアスしている
     「 test -f /bin/sh 」=「 [ -f /bin/sh] 」
 ファイルの存在を判断する
     test -e FILE ファイルが存在するか?
     test -d FILE ファイルが存在し、それはディレクトリか?
     test -f FILE ファイルが存在し、それは普通のファイルか?
 文字列を判断する
     test -n STRING 0文字以上の文字列か?
     test -z STRING 0文字の文字列か?
     test STRING1 = STRING2
     test STRING1 != STRING2
 整数値を判断する
     test INTEGER1 -eq INTERT2 EQual
     test INTEGER1 -ne INTERT2 Not Equal
     test INTEGER1 -gt INTERT2 INTEGER1 is Greater Than INTEGER2
     test INTEGER1 -ge INTERT2 INTEGER1 is Greater than or Equal to INTEGER2
     test INTEGER1 -lt INTERT2 INTEGER1 is Less Than INTEGER2
     test INTEGER1 -le INTERT2 INTEGER1 is Less than or Equal to INTEGER2

過去のファイルを消す

find /usr/hogehoge -daystart -ctime +3 -exec rm -rf {} \;

find . -name \*~ | xargs ls -la
find . -name \*~ | xargs rm

for FILE in /home/sample/*.txt
do
  mv ${FILE} /home/sample/backup/
done
bash.txt · 最終更新: 2019/06/30 12:22 by 127.0.0.1