Working with files
- list contents of the current directory – ls
- Get the contents of file(display in terminal) – cat
- To get total no of lines and words and characters of line – wc
-
Pass arguments with the commands to perform special functions
if you want to get permissions and file informations using ls command add argument -l so will display the properties of all the files in current directories and last access time and last update time
even you can pass the file name as argument to get the file properties
[shell_usr@localhost ~]$ ls -l new_file
-rw-rw-r–. 1 shell_usr shell_usr 441 2009-11-07 07:53 new_file
[shell_usr@localhost ~]$
usually single letter commands start with – (like -l) and if word arguments will start with –
5. Copy file – cp
syntax :
cp [OPTION]… [-T] SOURCE DEST
cp [OPTION]… SOURCE… DIRECTORY
cp [OPTION]… -t DIRECTORY SOURCE…
want more information
use the man pages by typing man cp or you can get the man pages from on-line in this link
[shell_usr@localhost ~]$ ls -l new_file
-rw-rw-r–. 1 shell_usr shell_usr 441 2009-11-07 07:53 new_file
[shell_usr@localhost ~]$ cp new_file newestfile
[shell_usr@localhost ~]$ ls -l
total 16
-rw-rw-r–. 1 shell_usr shell_usr 441 2009-11-07 09:21 newestfile
-rw-rw-r–. 1 shell_usr shell_usr 441 2009-11-07 07:53 new_file
-rw-rw-r–. 1 shell_usr shell_usr 407 2009-11-07 07:52 new_file~
-rw-rw-r–. 1 shell_usr shell_usr 0 2009-11-07 07:49 new_file_2
drwxrwxr-x. 2 shell_usr shell_usr 4096 2009-11-07 07:48 test
[shell_usr@localhost ~]$
6.Rename or relocate your file – mv
syntax:
mv [OPTION]… [-T] SOURCE DEST
mv [OPTION]… SOURCE… DIRECTORY
mv [OPTION]… -t DIRECTORY SOURCE…
[shell_usr@localhost ~]$ ll
total 16
-rw-rw-r–. 1 shell_usr shell_usr 441 2009-11-07 09:21 newestfile
-rw-rw-r–. 1 shell_usr shell_usr 441 2009-11-07 07:53 new_file
-rw-rw-r–. 1 shell_usr shell_usr 407 2009-11-07 07:52 new_file~
-rw-rw-r–. 1 shell_usr shell_usr 0 2009-11-07 07:49 new_file_2
drwxrwxr-x. 2 shell_usr shell_usr 4096 2009-11-07 07:48 test
[shell_usr@localhost ~]$ mv new_file~ old_tmp
[shell_usr@localhost ~]$ ls -l
total 16
-rw-rw-r–. 1 shell_usr shell_usr 441 2009-11-07 09:21 newestfile
-rw-rw-r–. 1 shell_usr shell_usr 441 2009-11-07 07:53 new_file
-rw-rw-r–. 1 shell_usr shell_usr 0 2009-11-07 07:49 new_file_2
-rw-rw-r–. 1 shell_usr shell_usr 407 2009-11-07 07:52 old_tmp
drwxrwxr-x. 2 shell_usr shell_usr 4096 2009-11-07 07:48 test
[shell_usr@localhost ~]$
7. remove a file – rm
syntax:
rm [OPTION]… FILE…
[shell_usr@localhost ~]$ ls
newestfile new_file new_file_2 old_tmp test
[shell_usr@localhost ~]$ rm old_tmp
[shell_usr@localhost ~]$ ls
newestfile new_file new_file_2 test
[shell_usr@localhost ~]$



