Move content from directory to another


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Move content from directory to another
# 1  
Old 03-31-2011
Move content from directory to another

I have in root directory a folder A and a Folder B. I want to copy or move all content (many files) from A to B.

How do I do that UNIX style?

Thanks!
# 2  
Old 03-31-2011
Unless you have a quite enormous number of files sitting right inside /a, this is it:
Code:
mv /a/* /b/

# 3  
Old 03-31-2011
That's what I had in mind, but just wanted to be sure so no messing up Smilie And well there are a lot of files to be moved. Does that make any difference?
# 4  
Old 03-31-2011
If you want to copy or move everything on the directory, run cp or mv on the directory, not on the contents.

Code:
cp -rv a b

or
Code:
mv a b

if you would like to see a 'progress' status and rsync is available
Code:
rsync -rvP a/ b


Last edited by rmtzcx; 03-31-2011 at 05:34 PM.. Reason: Missing options to the commandes
# 5  
Old 03-31-2011
Ok I try that one and hope I get it right. Maybe it's about 50.000 files.
# 6  
Old 03-31-2011
What matters are how many entries are in a, not how much stuff there is in general.

for example, if /a contained these files:
Code:
f00000000
f00000001
...
f9999999

the shell would try and turn /a/* into /a/f0000000 /a/f0000001 ... /a/f9999999 and run out of space in the commandline. Many systems will let you cram in a few hundred filenames, but not thousands or billions.

But a folder inside a is no problem since /a/* just becomes /a/foldername. It doesn't have to cram one million filenames into the list, and the rest becomes mv's job, which it'll do fine.

How big this limit is varies from system to system, but if it's not thousands, you're probably okay.

[edit] 50,000? Yeah, rmt's method works better. I just usually don't like it since, if /b doesn't exist, mv will rename /a into /b instead!
# 7  
Old 04-01-2011
Thanks guys. I did the
Quote:
/*
command and that worked fine. Now I wonder what is the command for decompress a .bzip2 file? I first .tar the file and then made it .bzip2 and will now upload it to the server and need to decompress. How?

Another short question: When I log in to the server from SSH I don't come to the root catalog. Is there any smarter/faster way the printing cd ../../../../ ?

Thanks for all the help!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. Shell Programming and Scripting

How Create new directory and move files to that directory.?

Hi All, We have main directory called "head" under this we have several sub directories and under these directories we have sub directories. My requirement is I have to find the SQL files which are having the string "procedure" under "head" directory and sub directories as well. And create... (14 Replies)
Discussion started by: ROCK_PLSQL
14 Replies

3. UNIX for Dummies Questions & Answers

How to move gz files from one source directory to destination directory?

Hi All, Daily i am doing the house keeping in one of my server and manually moving the files which were older than 90 days and moving to destination folder. using the find command . Could you please assist me how to put the automation using the shell script . ... (11 Replies)
Discussion started by: venkat918
11 Replies

4. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

5. UNIX for Dummies Questions & Answers

move a file content to another directory

my script is: /u/user/orginal/:#! /bin/ksh find . -name "aur_prog*" -exec grep -il "error" > test.out #awk command to destination directory exit test.out file contain: ./aur_prog1.log ./aur_prog2.log ... (5 Replies)
Discussion started by: roughwal
5 Replies

6. Shell Programming and Scripting

move content from one file to another

i have a file like: COURSE NAME: operating systems CREDITS:4 123456 66 234567 80 567892 64 COURSE NAME: C# CREDITS: 5 123456 67 345688 95 234567 78 COURSE NAME: Java CREDITS: 4 245562 88 123456 93 278962 95 COURSE NAME: Oracle CREDITS:5 278962 86 (5 Replies)
Discussion started by: poonam29
5 Replies

7. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

8. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

9. UNIX for Dummies Questions & Answers

Move all files in a directory tree to a signal directory?

Is this possible? Let me know If I need specify further on what I am trying to do- I just want to spare you the boring details of my personal file management. Thanks in advance- Brian- (2 Replies)
Discussion started by: briandanielz
2 Replies
Login or Register to Ask a Question