0

Environments: SuSE 15 SP1 Problem: It is so strange that some latest filelist could not be output via the remote ssh ls -l .

jchadb2:/scripts # 
jchadb2:/scripts # 
jchadb2:/scripts # ls -ltr /scripts/*.sh
-rwxr-xr-- 1 root root 1519 Dec 23  2019 /scripts/hacfg_trans_v2.sh
-rwxr-xr-- 1 root root 1519 Dec 23  2019 /scripts/hacfg_trans.sh
-rwxr--r-- 1 root root 1550 Dec 31  2019 /scripts/hafile_trans_dos.sh
-rwxr--r-- 1 root root 1516 Dec 31  2019 /scripts/hafile_trans_ux.sh
-rwxr--r-- 1 root root 1497 Dec 31  2019 /scripts/hafile_trans.sh
-rwxr-xr-- 1 root root 1523 Dec 30 18:34 /scripts/habak_trans_v2.sh
-rwxr--r-- 1 root root 1548 Dec 31 10:57 /scripts/hafile_trans_v2.sh
-rwxr-xr-- 1 root root 1622 Dec 31 16:30 /scripts/habak_trans_v3a.sh
-rwxr--r-- 1 root root 1647 Dec 31 17:18 /scripts/hafile_trans_v3a.sh
-rwxr--r-- 1 root root 1647 Dec 31 17:18 /scripts/hafile_trans_v3.sh
jchadb2:/scripts # 
jchadb2:/scripts # 



jchadb1:/scripts # 
jchadb1:/scripts # 
jchadb1:/scripts # ssh jchadb2 ls -l /scripts/*.sh
-rwxr-xr-- 1 root root 1476 Dec 11  2019 /scripts/habak_trans.sh
-rwxr-xr-- 1 root root 1519 Dec 23  2019 /scripts/hacfg_trans.sh
-rwxr--r-- 1 root root 1550 Dec 31  2019 /scripts/hafile_trans_dos.sh
-rwxr--r-- 1 root root 1516 Dec 31  2019 /scripts/hafile_trans_ux.sh
-rwxr--r-- 1 root root 1497 Dec 31  2019 /scripts/hafile_trans.sh
jchadb1:/scripts # 
jchadb1:/scripts # 
1

you have files on jchab1:/scripts that match /scripts/*

so

ssh jchadb2 ls -l /scripts/*.sh

first, expand localy to

ssh jchadb2 ls -l /scripts/habak_trans.sh .. (no _v2 files)

next, ls -l /scripts/habak_trans.sh .. is sent to jchab2 (and still no _v2. file)

and on remote hosts, only explicit file are listed.

compare

ssh jchadb2 ls -l /scripts/*.sh

and

ssh jchadb2 ls -l /scripts/*_v*.sh

try escaping *

ssh jchadb2 ls -l /scripts/\*.sh
6
  • Great ! It really need \* <br/> – lylklb Jan 12 at 14:58
  • But how to understand that the wildcard "*" with remote ssh ls -l cannot expand/mismatch the "_v" ....? – lylklb Jan 12 at 15:07
  • I update my answer, be aware that command line is expanded localy before command part in ssh is sent to remote host. – Archemar Jan 12 at 15:12
  • My doubt is why the same "*" just cannot expand/mismatch the "_v" ? – lylklb Jan 12 at 15:40
  • because there is _v2 files on jcab1 – Archemar Jan 12 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.