Skip to content

Commit a3b140e

Browse files
author
lerndevops
authored
Create file-operations.md
1 parent dda66af commit a3b140e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

linux/basics/file-operations.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## file operations
2+
3+
### Create Files
4+
```
5+
touch abc.txt -- creates a empty file
6+
ls -l -- lists the contents in current directory
7+
8+
```
9+
VI Editor
10+
11+
vi abc.txt -- creates & opens the file in read only mode if the file is not exist
12+
13+
to edit the file, press 'i' on keyboard for INSERT mode & then you can write anything
14+
once required text is entered press 'ESC' on keyboard to back readonly mode
15+
press ':wq' on keyboard -- to save & come out of the file
16+
press ':q' on keyboard -- to come out of the file without saving
17+
press ':wq!' on keyboard -- to save forcefully & come out of the file
18+
press ':q!' on keyboard -- to come out of the file forcefully without saving
19+
( note: vi is an file editor, you can use any editor you like by installing it on your machine )
20+
```
21+
22+
### check / view the file contents
23+
24+
```
25+
cat abc.txt -- writes the content of file into terminal & exits
26+
```
27+
```
28+
more abc.txt -- writes the content of file on terminal page by page ( to move to next page need to hit space bar on keyboard )
29+
```
30+
```
31+
less abc.txt -- open the file on terminal & can be read line by line (use arrows to scroll up & down)
32+
33+
to comeout need to press 'q' on the key board
34+
```
35+
36+
### remove the file(s)
37+
```
38+
rm abc.txt -- to remove a file
39+
```
40+

0 commit comments

Comments
 (0)