Visit Our UNIX and Linux User Community

Saving files

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Saving files
# 1  
Old 04-20-2011
Saving files

Hi all,
I need to save my files at c, d or any drive location via script.

Say for example i have 10 files at location /usr/bi/ci location.
10 files naming
c.ksh and so on

I want to save the files and its content at some location (any drive on local computer)..How can this be achieve via script.

Now y iam asking this is because many time i have done rm * which is wrong but i have done this so wanted to backup these files and its content...


Last edited by zaxxon; 04-20-2011 at 04:51 AM.. Reason: expanding subject
# 2  
Old 04-20-2011
Would it work to just copy them with cp -p? If a rm did not do what you wanted, maybe a mv could be more close.
# 3  
Old 04-20-2011
Sorry thats not the answer for my question..
I need a script to copy all the files and its contents from a any directory structure to a particular location at ur hard drive
# 4  
Old 04-20-2011
Requirement is not clear. May be this is what you want?


cd $srcdir
for i in *
  cp $i $dstdir

what do you mean by saving the contents?

# 5  
Old 04-20-2011
Sorry thats not the answer for my question..
Do you have a card with the answer in your hand?

I need a script to copy all the files and its contents from a any directory structure to a particular location at ur hard drive
The easiest command to copy files is cp. When you copy a file, you always copy it's contents. Else it would not be copying but more like setting a link.
The command cp takes any local source and any destination as parameter.

So it answers your written question. Maybe rephrase your question.

Last edited by zaxxon; 04-20-2011 at 07:56 AM.. Reason: added "local"

Previous Thread | Next Thread
Test Your Knowledge in Computers #905
Difficulty: Easy
Generally speaking, Unix systems are commercial, closed source and propriety operating systems so it is expensive to customize for supercomputing projects. Linux, on the other hand, is free and easier to customize.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Saving files with file name as output

Hi, i need help with a file creation of an output program. I've got a program that with #find creates an output for each files in a directory. If i give this command : -o spec$(date -u +%Y%m%dt%H%M) it creates just one file, overwriting all the others since it is the creation date .... (2 Replies)
Discussion started by: Board27
2 Replies

2. Shell Programming and Scripting

Input not saving correctly in both files

If the user inputs two variants separated by a comma, the below command is supposed to write both variants to the GJ-53.txt and then to out.txt. Both are written to the GJ-53.txt, however only one is written to out.txt and I'm not sure why. Thank you :). gjb2() { printf "\n\n" ... (1 Reply)
Discussion started by: cmccabe
1 Replies

3. Shell Programming and Scripting

Read each line and saving the line in separate files

Hi Experts, I am having a requirement like this; Input file EIM_ACCT.ifb|1001|1005 EIM_ADDR.ifb|1002|1004 EIM_ABD.ifb|1009|1007 I want to read each line of this file and pass each line,one at a time,as an argument to another script. eg; first line->store it to a file->call... (2 Replies)
Discussion started by: ashishpanchal85
2 Replies

4. Shell Programming and Scripting

parsing txt file, saving graphics files

hi everyone, i am a newbie in shell programming. and i want to simply go through a text file that contains 3 "columns", split by ';' customerID ; link-to-contract ; save-as-filename so an example would simply look like this now i want to loop through every line, and save the file from... (3 Replies)
Discussion started by: Confidence
3 Replies

5. UNIX for Dummies Questions & Answers

Assistance with combining, sorting and saving multi files into one new file

Good morning. I have a piece of code that is currently taking multiple files and using the CAT.exe command to combine into one file that is then sorted in reverse order based on the 3rd field of the file, then displayed on screen. I am trying to change this so that the files are being combined into... (4 Replies)
Discussion started by: jaacmmason
4 Replies

6. UNIX for Dummies Questions & Answers

Silly question-how i refer to the current directory when saving files

I want to save a bunch of files to a folder in my current directory. Ho do i refer to my current directory without writing all the path? (2 Replies)
Discussion started by: FelipeAd
2 Replies

7. Shell Programming and Scripting

recursive saving of files and folders

Hi all I have a bash script, that loops through a folders files and all subfolders for .shtml files. It looks for a string and replaces it, creating a backup of the original file. This all works great, but I'd like, when the backup is done, that the files are then also created in their... (4 Replies)
Discussion started by: terrid
4 Replies

8. UNIX for Dummies Questions & Answers

Saving or writing files in unicode - IS0-8859-5

Hi, I have problems in saving/writing files that contains Unicode characters - to be specific ISO-8859-5. The source file contains correct Unicode characters, should I add specific unix scripts before writing the said file? Many thanks, ahrong09 (0 Replies)
Discussion started by: ahrong09
0 Replies

9. UNIX for Dummies Questions & Answers

Crontab keeps saving empty files of the job file.

Hey, */20 * * * * /usr/bin/wget >/dev/nullthats what the crontab is setup todo, so basically every 20minutes it runs consume.php In my root directory, i'm getting files like this: consume.php consume.php1 consume.php2 i woke... (3 Replies)
Discussion started by: iarp
3 Replies

10. Shell Programming and Scripting

saving a vi session

Apologies if this isn't quite the right thread I have a vi session and I have set a lot of tags with 'mx'. can I save this session preserving these tags so when I go back to the session I don't have to reset them all? cheers (0 Replies)
Discussion started by: ajcannon
0 Replies

Featured Tech Videos