shell - Unable to use wildcard for SSH command -


there number of files have check if exist in directory. follow standard naming convention aside file extension want use wild card e.g:

yyyymm=201403 file_list=`cat config.txt` file in $file_list     file=`echo $file | cut -f1 -d"~"`     search_name=$file$yyyymm     answer=`ssh -q userid@servername 'ls /home/to/some/directory/$search_name* | wc -l'`     returnstatus=$?     if [ $answer=1 ];         echo "file found"     else         echo "file not found"     fi done 

the wildcard not working, ideas how make visible shell?

i had same question now. in despair, gave , used pipes grep , xargs wildcard-like functionality.

was (none of these worked - , tried others):

ssh -t r@host "rm /path/to/folder/alpha*"     ssh -t r@host "rm \"/path/to/folder/alpha*\" " ssh -t r@host "rm \"/path/to/folder/alpha\*\" " 

is:

ssh -t r@host "cd /path/to/folder/ && ls | grep alpha | xargs rm" 

note: did of troubleshooting ls instead of rm, in case surprised myself.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -