Menu

UNIX TUTORIALS - Unix - File Management

Unix - File Management

ADVERTISEMENTS

Listing Files:

PrefixDescription
- Regular file, such as an ASCII text file, binary executable, or hard link.
b Block special file. Block input/output device file such as a physical hard drive.
c Character special file. Raw input/output device file such as a physical hard drive
d Directory file that contains a listing of other files and directories.
l Symbolic link file. Links on any regular file.
p Named pipe. A mechanism for interprocess communications
s Socket used for interprocess communication.

ADVERTISEMENTS

Listing Files:

$ls

ADVERTISEMENTS

$ls

bin        hosts  lib     res.03
ch07       hw1    pub     test_results
ch07.bak   hw2    res.01  users
docs       hw3    res.02  work

$ls -l
total 1962188

drwxrwxr-x  2 amrood amrood      4096 Dec 25 09:59 uml
-rw-rw-r--  1 amrood amrood      5341 Dec 25 08:38 uml.jpg
drwxr-xr-x  2 amrood amrood      4096 Feb 15  2006 univ
drwxr-xr-x  2 root   root        4096 Dec  9  2007 urlspedia
-rw-r--r--  1 root   root      276480 Dec  9  2007 urlspedia.tar
drwxr-xr-x  8 root   root        4096 Nov 25  2007 usr
drwxr-xr-x  2    200    300      4096 Nov 25  2007 webthumb-1.01
-rwxr-xr-x  1 root   root        3192 Nov 25  2007 webthumb.php
-rw-rw-r--  1 amrood amrood     20480 Nov 25  2007 webthumb.tar
-rw-rw-r--  1 amrood amrood      5654 Aug  9  2007 yourfile.mid
-rw-rw-r--  1 amrood amrood    166255 Aug  9  2007 yourfile.swf
drwxr-xr-x 11 amrood amrood      4096 May 29  2007 zlib-1.2.3
$

Meta Characters:

$ls ch*.doc

ch01-1.doc   ch010.doc  ch02.doc    ch03-2.doc 
ch04-1.doc   ch040.doc  ch05.doc    ch06-2.doc
ch01-2.doc ch02-1.doc c

$ls *.doc

Hidden Files:

$ ls -a

.         .profile       docs     lib     test_results
..        .rhosts        hosts    pub     users
.emacs    bin            hw1      res.01  work
.exrc     ch07           hw2      res.02
.kshrc    ch07.bak       hw3      res.03
$

Creating Files:

$ vi filename

This is unix file....I created it for the first time.....
I'm going to save this content in this file.

$ vi filename
$

Editing Files:

$ vi filename

Display Content of a File:

$ cat filename
This is unix file....I created it for the first time.....
I'm going to save this content in this file.
$

$ cat filename -b
1   This is unix file....I created it for the first time.....
2   I'm going to save this content in this file.
$

Counting Words in a File:

$ wc filename
2  19 103 filename
$

$ wc filename1 filename2 filename3

Copying Files:

$ cp source_file destination_file

$ cp filename copyfile
$

Renaming Files:

$ mv old_file new_file

$ mv filename newfile
$

Deleting Files:

$ rm filename

$ rm filename
$

$ rm filename1 filename2 filename3
$