Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
haddしてから足しあわせた数をファイル名に追加するだけのスクリプト。while read 以下のloopの中でexprを使ってnadd+1をやろうとしたのになぜかできなかった。しかたないのでリダイレクトしてごにょごにょ。
#!/bin/bash
#hadd_and_rename.sh target.root sources.root
if [ $# -lt 2 ]
then
echo "Number of argument is wrong. Exit hadd_and_rename.sh..."
exit
fi
#declare -i nadd
#nadd=0
#nadd=`expr $nadd + 1`
touch $1.tmp
hadd $@ | while read f
do
echo $f
source=`echo $f | grep "hadd Source file"`
if [ "$source" ]
then
echo "test" >> $1.tmp
fi
done
nadd=`cat $1.tmp | wc -l`
rm $1.tmp
echo "nadd = $nadd"
addname=`echo $1 | sed s/.root/-$nadd.root/g`
mv $1 $addname
echo "$addname created."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment