Bash - manually cp-r


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash - manually cp-r
# 1  
Old 03-16-2014
Bash - manually cp-r

hi guys i want a script manually copy all directories and files. Dont want to use cp-r, cp-R or any variant. How to do this, the piece of code i need is commented in the script


Code:
#!bin/bash

IFS=$'\n'

if test "$1" = ""
then
wd=pwd
else
wd=$1
fi

for file in $(find $1)
do
if [ -f $file ]; then
cp $file ~/Desktop
elif [ -d $file ]; then
#copy directory,subdirectory and files wihtout
#using cp-r, cp-R or any variant
mkdir ~/Desktop/$file
fi
done

thanks in advance

---------- Post updated at 10:17 AM ---------- Previous update was at 09:38 AM ----------

Something like, when a directory is found elif [ -d file ]; then

look in that directory if it contains more files or folders
create or copy folder and also containing files and folders

---------- Post updated at 11:49 AM ---------- Previous update was at 11:41 AM ----------

Avans highschool breda, the netherlands
course os1 exercise 4
# 2  
Old 03-16-2014
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling bash script works when called manually but not via Cron?

Hi, I've got a Bash backup script I'm trying to run on a directory via a cron job nightly. If I ssh in and run the script manually it works flawlessly. If I set up the cron to run evertything is totally messed up I don't even know where to begin. Basically the path structure is ... (6 Replies)
Discussion started by: wyclef
6 Replies

2. Solaris

Create rpool manually

Hi All; My server's root partition was encapsulated with VxVM, I try to convert it to ZFS. I successfully de-encapsulated root. Now I try to mirror 2 root disks using ZFS. But I receive following error: # zpool create rpool mirror c0t0d0s0 c0t1d0s0 invalid vdev specification use '-f' to... (6 Replies)
Discussion started by: reseki
6 Replies

3. Shell Programming and Scripting

Bash - manually cp-r

hi guys i want a script manually copy all directories and files. Dont want to use cp-r, cp-R or any variant. How to do this, the piece of code i need is commented in the script #!bin/bash IFS=$'\n' if test "$1" = "" then wd=pwd else wd=$1 fi for file in $(find $1)... (0 Replies)
Discussion started by: Wolverine89
0 Replies

4. Solaris

Is there a way to free up memory manually ?

Hi, I am wondering if there is a way to free up memory in Solaris manually ? the way we can do it in Linux for example : echo `/bin/date` "************* Memory Info Before *************" free -m sync echo 1 > /proc/sys/vm/drop_caches echo 2 > /proc/sys/vm/drop_caches echo 3 >... (13 Replies)
Discussion started by: terrykhatri531
13 Replies

5. Shell Programming and Scripting

Manually built the code below.

Hi All, I am faced with a problem. I came to know that large scale problems in MATLAB are very slow and with loops they are even slower. I have the MATLAB script below that does some large scale computation for my school project work. I've been running this code for long now but all it did... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

6. Solaris

Adding Broastcaste i.p manually

Hi, I am trying to add one interface manually using plumb command. After that it is showing point to point communication. But it should show broadcaste. ce3: flags=1000851<UP,POINTOPOINT,RUNNING,MULTICAST,IPv4> mtu 1500 index 6 inet 10.136.11.225 --> 10.136.11.1 netmask... (2 Replies)
Discussion started by: kkarthik_kaja
2 Replies

7. Solaris

Manually editing partition table

I'm manually editing the partition table purely for experimenting. I did prtvtoc /dev/dsk/c1t0d0s2 > /tmp/prtvtoc I'm trying to split up partition 5 to make partition 6. I'm running into a cylinder boundary error on partition 6. Any clues? # vi /tmp/prtvtoc "/tmp/prtvtoc" 23 lines, 769... (1 Reply)
Discussion started by: adelsin
1 Replies

8. Solaris

How can I edit the mailbox manually

I use gmail to POP my account because of the spamfilter. From time to time I receive an error message "Connection timed out: There may be a problem with the settings you added. Ple..." after this I am no longer able to retrieve my mails because of the blocked session: "... (1 Reply)
Discussion started by: rolandk
1 Replies

9. UNIX for Advanced & Expert Users

how to implement patch manually

dear all, i got a pach file for ns 2.3 but it is not working properly i want to imlement those modification in the concering file manualy by onpening patches and write them in the orignal souce . Plz let me know how it is possible ? thanks (1 Reply)
Discussion started by: sheilly_2k7
1 Replies

10. UNIX for Dummies Questions & Answers

Works Manually - not in CRON

I've got a ksh script that works like a charm when I run it manually. When I set it up in a cron, I keep getting this error in my log: syntax error at line 90: `$' unexpected Here's my snippet of code starting at line 90: while ] do sleep 900 done What's the... (5 Replies)
Discussion started by: dstinsman
5 Replies
Login or Register to Ask a Question