2 File Manipulation

mkdir test
mkdir -p test/test1

mkdir [options] <Directory>. Make a directory. Option is for adding other paths.

rmdir test/test1

rmdir [options] <Directory>. For this command, the directory must be empty before it may be removed. So now the test directory will be empty. Be careful with the remove command line, since it can not be undone. Once you’ve removed it, it’s a gonner.

cd test
mkdir foo
touch example1

touch [options] <filename> Create a blank file named example1.

cp example1 barney
cp -r foo foo1

cp [options] <source> <destination>. Copy a file or directory. Copies the example1 file and name it barney. Note that both source and destination can be paths. When using cp, the destination can be a path to either a file or directory.

mkdir backups
mv foo1 backups/foo2
mv barney backups/

mv [options] <source> <destination>. Moving the file. The line above means that :

The example above shows that mv can be used to change names of a file. Now if we specify the destination to be the same directory as the source, but with a different name, then we have effectively used mv to rename a file or directory.

rm example1
rm -r backups

rm [options] <file>. Remove a file.

3 WildCards

Wildcards are a set of building blocks that allow you to create a pattern defining a set of files or directories. The basic set :

touch barry.txt
touch blah.txt
ls b*
ls *.txt

The command line create two .txt file name barry and blah.

ls *.???

List every file with a three letter file type.

ls [fb]*
ls [^f]*

The range operator allows you to limit to a subset of characters. So

4 Reference

  1. Linux Tutorial : http://ryanstutorials.net/linuxtutorial/navigation.php