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



Download 122.5 Kb.
Page5/17
Date25.10.2023
Size122.5 Kb.
#62396
1   2   3   4   5   6   7   8   9   ...   17
Unix Commands
Working with Files:

Creating a File

  • Syn: $ cat > [file name]

  • Ex: $ cat >file1

Enter the data you want and press (control key + d) to save & quit from file1
NOTE: With cat command we can only create a single data file. To create multiple files is not possible through cat command it is possible with touch command.

Syn: $ touch [file1] [file2] [file3] [file4] …..
Touch command is used to create multiple empty files. The data should be entered later using vi editor.

Cat command is also used to display the data in the file.
Syn: $ cat < [file name] or $ cat [file name]
Here the symbol ‘<’ is optional.
Note: With cat command we can create file and display data in the file but we cannot modify the data of a file.
Ex: $ cat file1
bmnxbcmnxb
cjdbcnbdncbdmns



With cat command multiple files data can be displayed.
Syn: $ cat [file1] [file2] [file3] ….
The data of the files will be displayed sequentially one after the other.

  • Copying files

To copy the data of one file to another file cp command is used.
Syn: $ cp [source file] [destination file]
If the destination file already exist then data of source file overrides the destination file data. If does not exist it creates a new file.
Ex: $ cp file1 file2
If the destination file exist, to get confirmation from user to override the data or not –i option is used
Syn: $ cp –i [source file] [destination file]  to get confirmation to override.
If the file exist only it will ask for confirmation otherwise it create new file.
Ex: $ cp –i file1 file2
Overwrite y/n? –
The file is deleted only if option ‘y’ is entered, other than ‘y’ any char is entered the will not be deleted.
1   2   3   4   5   6   7   8   9   ...   17




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

    Main page