LoginSignup
0
1

More than 5 years have passed since last update.

shellでSQL発行してグルグル

Last updated at Posted at 2017-04-05

備忘として

DBはpostgreSQL

shellでselect発行しidを配列に入れグルグルでid名フォルダを消す。


#!/bin/sh
Array=()
idx=0
while read ii
do
    echo $ii
    Array[$idx]=$ii
    idx=$(( $idx+1 ))
done<<_EOT_
$( psql -d forth -U dbuser -F $'\n' -Atc"SELECT id FROM table WHERE id " )
_EOT_

echo "--------------------------"
for aa in "${Array[@]}"; do
    ## echo はテスト用本来は rm でフォルダを消す
    echo "/home/masa/work/"$aa
    ##rm -rf "/home/masa/work/"$aa
done
echo "--------------------------"

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1