Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bash script on different input

Status
Not open for further replies.

xiaoleiqq

Programmer
Aug 30, 2006
43
US
I am writing a bash script that reads different directory by user input, e.g., the user can use
"sh run folder1" or "sh run folder2" to go into different dir to open files.
Since I am a newb to script language and I am not sure how to write this, any suggestion is appreciated.
 

Is it Homework?


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
nah. I used to use perl to do script, but the system administrator won't install cpan module on one of the system and he suggest me use "rsync" to copy file to different server, where I need to enter password when i try to copy, i try write simple bash script to enter the password but it wont work,
 
and i was thinking using a loop to go through all the directory to copy necessary files ...
I am ok with manual input password, but not sure how to get the loop when the end of loop must be specific by the user...
 

Depending on what you need to do, you may not require a "loop", for example to copy files from one directory to another try this:
Code:
#!/bin/ksh
find $1 -type f -exec cp {} /another/dir \;
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top