Commands: $ logname  to check present working user. User2 $ clear



Download 122.5 Kb.
Page6/17
Date25.10.2023
Size122.5 Kb.
#62396
1   2   3   4   5   6   7   8   9   ...   17
Unix Commands
Rename a File

To rename a file mv command is used.
Syn: $ mv [old name] [new name]
If the new name already existed the old name will be renamed to new name and new name data will be overridden by old name data.
Ex: $ mv file1 filex
Here also to get confirmation we can use –i option.

  • Removing a file

To delete a file rm command is used.
Syn: $ rm [file name]
Ex: $ rm file1

To check the differences between the data of two files cmp command is used. But it displays only the first difference.
Syn: $ cmp file1 file2
To display all the differences between the files diff command is used.
Syn: $ diff file1 file2
Note: Comparison between the files of different users is possible only when the present working user has the access permission on the other user.

  • Removing multiple files

To remove multiple files also rm command is used.
Syn: $ rm file1 file2 file3 file4 …..
Here all the files which are entered will be deleted. If we want confirmation from user to delete the files –i option is used
Syn: $ rm –i file1 file2 file3 file4 ….
Ex:
$ rm –i file1 file2 file3 file4
Remove file1 y/n? y
Remove file1 y/n? n
Remove file1 y/n?
Remove file1 y/n? x
Here only file1 is deleted. Other than option y if you type any character the file will not be deleted.

  • Knowing file types

To know the type of the file, file command is used.
Syn: $ file [file name]
It displays the file type like exe, ascii, ZIP file etc.,
Ex: $ file file1
ASCII text
$ file file.zip
ZIP archive
1   2   3   4   5   6   7   8   9   ...   17




The database is protected by copyright ©ininet.org 2024
send message

    Main page