Friday, July 22, 2011

Playing with files in Linux command line

Now lets have some fun with files in linux terminal.

The simplest way to create a file is as follows

cat >hello.txt

this is a very good message

when you finish typing the matter press ctrl+d to save and close the file.

this will create a file named hello.txt with the matter "this is a very good message".

Now to view the content of a file type

cat file_name

for example: cat anil.txt

This will display the contents of file anil.txt

now to copy a file from a source to destination we use cp command .
Syntax is as follows

cp source destination

for example to copy the file anil.txt from /media/vol1/anil  to  /media/vol2/anoop


cp /media/vol1/anil/anil.txt /media/vol2/anoop

above command will cpoy the file "anil.txt" located in /media/vol1/anil to the loacation /media/vol2/anoop

to delete a file type

rm filename

for example to delete the file anil.txt type

rm anil.txt


 



0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes