Nicol
November 6, 2003, 7:57am
1
I wrote a shell script (AIX) to extract the file "/rep1/toto" from all the hosts referred in a list and send them to one local directory named ~/$host-$file with the hostname as prefix
rcp -p user@host:/rep1/$file ~/$host-$file
where file = toto ==> it works !
I would do the same thing but with "/rep1/toto*" (all files beginning with toto in /rep1 ) and naming these files "$host-$file"
for example : host1-toto1 ; host1-toto2 etc...
could someone help me , please
thanks in advance
christian
davidg
November 6, 2003, 8:19am
2
for i in `rsh $server "ls /rep1/"`
do
rcp /rep1/${i} mycomefromserver:/path/to-dir/${server}-${i}
done
Regs David
Nicol
November 6, 2003, 8:40am
3
Thanks for your answer , but first i would test if i enter :
/rep1/toto or
/rep1/toto* , in other words if the input contains a "*"
to do or not the loop
i'm searching for the test , if you have the answer please welcome !
christian
Ygor
November 6, 2003, 9:36am
4
Try
case $INPUT in
*\*) echo input ends with a star;;
*) echo otherwise;;
esac
Nicol
November 6, 2003, 10:17am
5
Thanks that's right ,
last thing , for the same script i would extract the filename from a string whether the string is short or long :
/rep1/rep2/rep3/file => file
or /rep1/file => file
i'm trying with awk command and NR parameter without success at this time , maybe (for sure) you will find before me ?
thanks
christian
Ygor
November 6, 2003, 10:44am
6
For sure, lookup the dirname and basename commands
basename /rep1/rep2/rep3/file
Nicol
November 6, 2003, 10:52am
7
in french , we say "bon dieu mais c'est bien s�r"
=> oh god for sure
sorry i'm surely tired , it was so simple !
thanks a lot
christian