"""
Copying Files and Directories
Commands
cp file1 file2 Copy contents of file1 to file2
cp file1 file2 file3 dir1 Copy file1,file2,file3 to dir1
cp -r dir1 dir2 copy dir1 contents to dir2.
You can use cp -i file1 file2 for interactive mode.
For copying directories cp -r is a must.
Explaining Screenshot.
cd Desktop
Changes my directory to Desktop.
nano file1
creates a file called file1.You enter some info.Once you are done press (ctrl+o) followed by hitting enter and lastly
ctrl+x to exit
To create a file named file1
[nano file1 --> fill some info --> ctrl+0 -->hit enter-->ctrl+x ]
cat file1
It displays the contents of file1
cp file1 file2
It creates a new file called file2 in the same directory with the contents of file1.
[* Here we didn't give any path,we just gave two file names.what if we want to copy file1 to another directory.
In that case use full paths.
cp source-file destinatio-file
cp /home/cam/Desktop/file1 /home/cam/file2
The above command copies file1 which is on my Desktop to my cam diectory which is in home ]
mkdir blog-promotion
It creates a new directory called blog-promotion on my Desktop.
cp file1 file2 blog-promotion
copies both file1 and file2 to a folder or directory called blog-promotion.
ls blog-promotion
shows all files and directories inside blog-promotion.
cd ..
Takes me to previous directory.
skipping to end.
cp -i
Before replacing a file which already exists it will ask you...that's called interactive
"""
Learn python for fun.The popular blog with questions and answers to the python.Solutions to facebookhackercup,codejam,codechef.The fun way to learn python with me.Building some cool apps.
No comments:
Post a Comment