LinuxQuestions.org
Register a domain and help support LQ
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 08-11-2011, 09:59 AM   #1
Juanmadrid
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Rep: Reputation: Disabled
Please help! simple bash script


is these oke?

#! / Bin / bash
cp /tmp/programming/practise/*.jpg /tmp/programming/practise/*music* /tmp/programming/Juan

I want tomake a script which copy 2 types of files from one directory to another! Thank you for your time!
 
Old 08-11-2011, 10:10 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,131
Blog Entries: 2

Rep: Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833
Quote:
Originally Posted by Juanmadrid View Post
is these oke?

#! / Bin / bash
cp /tmp/programming/practise/*.jpg /tmp/programming/practise/*music* /tmp/programming/Juan

I want tomake a script which copy 2 types of files from one directory to another! Thank you for your time!
Hello, and welcome to LQ!

At first, please use code-tags when posting code.

I found only one error in your script, this line:
Code:
#! / Bin / bash
This should be
Code:
#! /bin/bash
Linux is case-sensitive, unlike Windows Bin and bin are not the same. Since this is the path to the interpreter for that script it may not contain spaces that are not in the path, and if there are spaces in the path they have to be escaped.
 
Old 08-11-2011, 10:20 AM   #3
Juanmadrid
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thank you for your fast response!
so script is oke when that error is corrected?

Last edited by Juanmadrid; 08-11-2011 at 10:21 AM.
 
Old 08-11-2011, 10:27 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Should be. What happens when you try it?
 
Old 08-11-2011, 10:37 AM   #5
Juanmadrid
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
should I remove / on beginning of location so it should be tmp/programming/practise/*.jpg
 
Old 08-11-2011, 10:44 AM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,131
Blog Entries: 2

Rep: Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833
Paths beginning with / are absolute paths, paths without leading / are relative paths. A relative pathe will every time be interpreted from the current working directory, while the absolute path will always be interpretted from the root directory (/).
That means, if you don't use the leading / and your current directory doesn't contain a tmp/programming/ directory your script will not work.

For a better understanding of paths in Linux you may want to read this.

Last edited by TobiSGD; 08-11-2011 at 10:45 AM.
 
Old 08-11-2011, 10:44 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
Depends ... is the path to where the files are under /tmp or the tmp directory where you launch the script?
 
Old 08-11-2011, 10:56 AM   #8
Juanmadrid
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
oh nice explanations thank you!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Simple bash script please help! Cheloo Linux - General 3 07-13-2008 04:54 PM
Simple Bash Script sachinh Linux - General 5 05-23-2007 10:54 PM
Simple bash script help zok Linux - General 4 12-15-2006 12:56 PM
Need simple bash script help rickenbacherus Linux - General 1 11-01-2006 03:44 AM
Simple Bash Script Help njdownes Programming 2 03-05-2005 08:35 AM


All times are GMT -5. The time now is 02:27 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration