We are executing below commands
rm -f $folder_name/filename*
cp $folder_name1/filename1* $folder_name/
After checking the execution log we get following command executions
rm -f '/home/user/file*'
cp /home1/user1/file1* /home/user/
Why rm
executes with a single quote and not cp
command?
Chances are you are examining the output of bash -x
which adds single quotes around arguments just for disambiguation. But the code you are showing could not result in the output you describe.
rm wildcard*
will expand to rm
and the matching files if the wildcard has matches. If it doesn't, though, the expansion will be the equivalent of
'rm' 'wildcard*'
where I have added quotes just to indicate that no further evaluation will take place, similary to what bash -x
(and at least some variants of sh -x
) does.