Friday, March 16, 2012

How to create a file

1. touch [create blank file]

2. cat [create blank file,no edit but line can be added]

3. vi [everything can be done]

Creating a file with touch editor

# touch file_name [to create a blank file]

# touch /home/file_name [to create a file in home directory from root directory]

# touch folder_name a1 a2 a3 [ to create more than one file at a time ]

Creating a file with cat editor

# cat > file_name , then write & press Ctrl+D to save.

# cat > file_name [to read a file]

# cat >> file_name [to write in a file from last line]

Creating a file with vi editor

# vi file_name [to create a file, #vi -O a1 a2 (two file at a time),ctrl+w n/s/v/↕]

Then press ‘ i ’ to write and then press ‘Esc’ then write,

1. :w -> to save and exist.

2. :wq -> to save and quit.

3. :q -> to quit.

[ *If files are not save/quit then force the file with ‘ ! ‘, such as write :q! to quit ]

[* Copying line-> press ‘yy’/’4yy’, Deleting line -> press ‘dd’/ ’4dd’ , Paste-> press ‘p’.]

No comments:

Post a Comment