LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-19-2012, 01:21 AM   #1
tomislav91
Member
 
Registered: Apr 2012
Posts: 46

Rep: Reputation: Disabled
positional parameters script making


I was going to make some script file that must coping one folder(for example: /home/movies/terminator2) to another(that another folder must be parameter )
please help.
 
Old 04-19-2012, 01:24 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi and welcome to LQ,

Is there a question somewhere? We are more then willing to help, but we don't do all the work for you.

What have you tried? What did or did not work?
 
Old 04-19-2012, 09:13 PM   #3
RootAround
LQ Newbie
 
Registered: Oct 2010
Posts: 6

Rep: Reputation: 0
Smile

I'm not sure whether you want to copy the directory and its contents, or just its contents. But here's a script to get you started. It addresses both cases.

The directory "thisdir" has a file in it, but "thatdir" is an empty directory
This script, copy.sh, takes one parameter, $1. The 1st copy will copy just the contents of thisdir, not the directory structure itself. The 2nd copy copies the entire thisdir directory--with its contents-- to thatdir.

Here's the copy.sh script
---------------------------------------------------
#copy the contents of -thisdir- to -thatdir-
cp -t $1 thisdir/*.*
#copy the directory -thisdir- into -thatdir
cp -r thisdir $1
echo "the contents of -thisdir- and the directory now in -$1-"
---------------------------------------------------------

After creating it, invoke copy.sh by keying in;
------------------------------------------------------
./copy.sh thatdir
-------------------------------------------------------
I'm using "thatdir" as the parameter, but you can create/use your own directories.

Note that you have to enable the execution of copy.sh with
chmod +x copy.sh

Here are some links you might find useful:

Linux Commands
Shell Script Beginners Handbook
Bash Scripting Tutorial

Hope this helps. It's always tough for a newbie.

Last edited by RootAround; 04-19-2012 at 09:17 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
perl positional parameters/ casperdaghost Programming 6 11-11-2011 01:08 AM
HELP! Positional Parameters are giving me a headache! Scott_82 Linux - Newbie 7 05-06-2007 03:32 PM
shell: positional parameters... neidias Programming 1 04-04-2005 02:45 PM
Positional Parameters (arguments) desbyleo Solaris / OpenSolaris 2 10-25-2004 11:51 AM
Help with positional parameters Read_Icculus Linux - General 7 11-02-2003 04:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration