Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> Bourne Shell Scipts, Copy files
philmetz
post Oct 1 2008, 04:22 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 5
Joined: 29-September 08
Member No.: 13,687



Hi
I am trying to create a bourne shell script that will simply copy a file given command line arguments (first = file to copy, 2nd = name of second copy)

How can say copy a file?
I thought I could try:
#!/bin/sh
file1=$1
file2=$2
echo "File 1 is" $file1
echo "File 2 is" $file2

cp file1 file2


but doesnt work
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
philmetz
post Oct 1 2008, 04:38 AM
Post #2


Whats this Lie-nix Thing?
*

Group: Members
Posts: 5
Joined: 29-September 08
Member No.: 13,687



Ok i fixed it, forgot to add $
But got a new problem, is there a relationship operator in sh like AND(&&)?
I am trying the following:
#!/bin/sh
file1=$1
file2=$2
if [ $# = 2 && -e $file1]
then
echo "File 1 is" $file1
echo "File 2 is" $file2
cp $file1 $file2
else
echo "ERROR: Not enough command line arguments OR file does not exists!"
fi

So is there a way i can use &&
?
Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st October 2017 - 02:46 PM