My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Thursday, February 17, 2011

Unix Commands related to Handling files

Without an introductory speech let me come directly to the point.
Listing files in a directory

ls
list the files in the current directory
ls -a
list ALL files, even ones which begin with a dot, which are normally omitted
ls -s
list files, with their sizes
ls -l
list files, giving full details about each file
ls -al mydir/
list all files in directory mydir (including those beginning with a dot), giving full details about each file
ls *.c
list the files which end ".c"
ls mydir/
list the files in directory mydir


Moving or renaming files (IMHO please consider both the same if you are on Unix flavored OS or on Mac)
Examples:
mv oldname newname
rename a file
mv myfile mydir
move a file into another directory
mv myfile1 myfile2 myfile3 mydir
move several files into another directory


To Copy files
Examples:
cp oldname newname
make a copy of a file
cp myfile mydir
make a copy of a file in another directory
cp myfile1 myfile2 myfile3 mydir
make a copy of several files in another directory


To Delete files
Examples:
rm file...
delete the specified files
rm -i file...
ask for confirmation before deletion
rm -f file...
don't ask for confirmation before deletion. BE CAREFUL!
rm -r directory
Delete directory and everything in it. BE CAREFUL! To remove empty directories, see rmdir
rm -rf directory
Delete directory and everything in it, without asking for confirmation. Hey man its not the magic. Actually –rf tells the OS to suppress asking for confirmation. Actually there is never a magic in Software Arena. It’s all how deeper you go, and how diversified the developers approached to a problem. But defects/bug usually come as a magic!! (Some say, if you understand a woman, it is a magic in itself. Have I understood my Girlfriend and would be wife yet!!!!)


You can write me at toughjamy@yahoo.com.
To Know me professionally visit ..Linked In..
You can befriend me at ..FaceBook..
Read jokes at ..Jokes Limitless..
You can also know more about me at ToughJamy : An Informal Me!!

No comments:

Post a Comment