Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i write bash file to copy files from unix to windows and i pass the path of files as parameter to bash file :- scp -r /$1/ user@hostname:/cygdrive/c/unix_file

when i execute the bash and don't pass any parameter it is copy all file in "current directory "

example :-

roor@hostname/>./ now it copy all file in root .... when i test exit code it is equal ( 0 ) !!!!

share|improve this question
up vote 1 down vote accepted

If you don't pass an argument then its parameter value is considered to be an empty string. Test the parameter for a zero-length string (with if and [ or [[) and fail if it is one. And don't forget to quote the parameter in the command (scp ... /"$1"/ ...).

share|improve this answer

If you want to specify a default directory that will be in effect if you don't supply a parameter:

scp -r "/${1:-default/directory}/" user@hostname:/cygdrive/c/unix_file

in which you would replace "default/directory" with whatever you'd like.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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